You are here

public function FeatureContext::referenceUnitsInTheField in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

@Given /^reference units "(?<unit_names>[^"]*)" in the "(?<field_name>[^"]*)" field$/

File

test/features/bootstrap/FeatureContext.php, line 860

Class

FeatureContext
Features context.

Code

public function referenceUnitsInTheField($unit_names, $field_name) {
  $table_id = drupal_clean_css_identifier($field_name . '-values');
  $items = $this
    ->getSession()
    ->getPage()
    ->findAll('css', 'table[id^="' . $table_id . '"] tbody tr');
  $delta = count($items) - 1;
  foreach (explode(',', $unit_names) as $unit_name) {
    $unit_id = $this
      ->findBookableUnitByName($unit_name);
    $this
      ->fillFieldByJS('availability_ref[und][' . $delta . '][unit_id]', $unit_name . " [unit_id:{$unit_id}]");
    $this->minkContext
      ->pressButton($field_name . '_add_more');
    $this->minkContext
      ->iWaitForAjaxToFinish();
    $delta++;
  }
}