You are here

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

Fills the constraint range field form.

Parameters

$minimum:

$maximum:

$constraint_type:

$start_day:

$start:

$end:

3 calls to FeatureContext::addAvailabilityConstraint()
FeatureContext::iAddAConstraintFromToMustStartOn in test/features/bootstrap/FeatureContext.php
@Given /^I add a constraint from "(?P<start>[^"]*)" to "(?P<end>[^"]*)" "(?P<constraint_type>[^"]*)" start on "(?P<start_day>[^"]*)"$/
FeatureContext::iAddAConstraintFromToMustStartOnAndTheMinimumIsAndTheMaximumIs in test/features/bootstrap/FeatureContext.php
@Given /^I add a constraint from "(?P<start>[^"]*)" to "(?P<end>[^"]*)" "(?P<constraint_type>[^"]*)" start on "(?P<start_day>[^"]*)" and the minimum is…
FeatureContext::iAddAnAlwaysConstraintWhereTheMinimumIsAndTheMaximumIs in test/features/bootstrap/FeatureContext.php
@Given /^I add an always constraint where "(?P<constraint_type>[^"]*)" start on "(?P<start_day>[^"]*)" and the minimum is "(?P<minimum>[^"]*)" and the maximum is…

File

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

Class

FeatureContext
Features context.

Code

protected function addAvailabilityConstraint($minimum = NULL, $maximum = NULL, $constraint_type = NULL, $start_day = NULL, $start = NULL, $end = NULL) {
  $items = $this
    ->getSession()
    ->getPage()
    ->findAll('css', 'table[id^="rooms-constraints-range-values"] tbody tr');
  $delta = count($items) - 1;
  if ($constraint_type == 'must') {
    $this->minkContext
      ->pressButton('add_checkin_day_' . $delta);
  }
  else {
    $this->minkContext
      ->pressButton('add_min_max_' . $delta);
  }
  $this->minkContext
    ->iWaitForAjaxToFinish();
  if (!isset($start) || !isset($end)) {
    $this->minkContext
      ->selectOption('rooms_constraints_range[und][' . $delta . '][group_conditions][period]', 'always');
  }
  else {
    $this->minkContext
      ->selectOption('rooms_constraints_range[und][' . $delta . '][group_conditions][period]', 'dates');
    $this->minkContext
      ->iWaitForAjaxToFinish();
    $start_date = new DateTime($start);
    $end_date = new DateTime($end);
    $this->minkContext
      ->fillField('rooms_constraints_range[und][' . $delta . '][group_conditions][start_date][date]', $start_date
      ->format('d/m/Y'));
    $this->minkContext
      ->fillField('rooms_constraints_range[und][' . $delta . '][group_conditions][end_date][date]', $end_date
      ->format('d/m/Y'));
  }
  if (isset($start_day)) {
    if ($constraint_type == 'must') {
      $this->minkContext
        ->selectOption('rooms_constraints_range[und][' . $delta . '][group_conditions][booking_must_start]', $start_day);
    }
    elseif ($constraint_type == 'if') {
      $this->minkContext
        ->checkOption('rooms_constraints_range[und][' . $delta . '][group_conditions][booking_if_start]');
      $this->minkContext
        ->iWaitForAjaxToFinish();
      $this->minkContext
        ->selectOption('rooms_constraints_range[und][' . $delta . '][group_conditions][booking_if_start_day]', $start_day);
    }
  }
  if ($constraint_type != 'must') {
    if (is_numeric($minimum)) {
      $this->minkContext
        ->checkOption('rooms_constraints_range[und][' . $delta . '][group_conditions][minimum_stay]');
      $this->minkContext
        ->iWaitForAjaxToFinish();
      $this->minkContext
        ->fillField('rooms_constraints_range[und][' . $delta . '][group_conditions][minimum_stay_nights]', $minimum);
    }
    if (is_numeric($maximum)) {
      $this->minkContext
        ->checkOption('rooms_constraints_range[und][' . $delta . '][group_conditions][maximum_stay]');
      $this->minkContext
        ->iWaitForAjaxToFinish();
      $this->minkContext
        ->fillField('rooms_constraints_range[und][' . $delta . '][group_conditions][maximum_stay_nights]', $maximum);
    }
  }
  $this->minkContext
    ->pressButton('rooms_constraints_range_add_more');
  $this->minkContext
    ->iWaitForAjaxToFinish();
}