You are here

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

@Then /^I navigate in the fullCalendar to "(?<month>[^"]*)"$/

File

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

Class

FeatureContext
Features context.

Code

public function iNavigateInTheFullcalendarTo($month) {
  $today = new DateTime();
  $final = new DateTime($month . '-1');
  $button_selector = $today > $final ? '.fc-prev-button' : '.fc-next-button';
  if ($today > $final) {
    $start = $final
      ->add(new DateInterval('P2M'));
    $end = $today;
  }
  else {
    $start = $today;
    $end = $final
      ->sub(new DateInterval('P1M'));
  }
  foreach ($this
    ->monthsBetweenDates($start, $end) as $month) {
    $element = $this
      ->getSession()
      ->getPage()
      ->find('css', 'button' . $button_selector);
    if ($element === NULL) {
      throw new \InvalidArgumentException(sprintf('Cannot find button: "%s"', $button_selector));
    }
    $element
      ->click();
    $this->minkContext
      ->iWaitForAjaxToFinish();
  }
}