You are here

public function FeatureContext::assertVariationEditMode in Acquia Lift Connector 7

@Then the variation edit mode is :state

File

behat-tests/features/bootstrap/FeatureContext.php, line 367

Class

FeatureContext
Defines application features from the specific context.

Code

public function assertVariationEditMode($expected_state) {
  if (!in_array($expected_state, array(
    'active',
    'inactive',
    'hidden',
    'disabled',
  ))) {
    throw new \Exception(sprintf('Invalid expected state for variation toggle: %s', $expected_state));
  }
  $element = $this
    ->findElementInRegion('#acquia-lift-menu-page-variation-toggle', 'lift_tray');
  if (empty($element)) {
    throw new \Exception(sprintf('The variation toggle edit link cannot be found on the page %s', $this
      ->getSession()
      ->getCurrentUrl()));
  }
  $current_state = 'inactive';
  if ($element
    ->hasClass('acquia-lift-page-variation-toggle-hidden')) {
    $current_state = 'hidden';
  }
  else {
    if ($element
      ->hasClass('acquia-lift-page-variation-toggle-active')) {
      $current_state = 'active';
    }
    else {
      if ($element
        ->hasClass('acquia-lift-page-variation-toggle-disabled')) {
        $current_state = 'disabled';
      }
    }
  }
  if ($current_state !== $expected_state) {
    throw new \Exception(sprintf('The variation toggle edit link is currently in the %s state and not the expected %s state.', $current_state, $expected_state));
  }
}