You are here

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

Checks, that form button, field, radio with specified id|name|label|value is disabled.

@Then /^the "(?P<select>(?:[^"]|\\")*)" (?P<type>(button)) is disabled$/ @Then /^the "(?P<select>(?:[^"]|\\")*)" (?P<type>(field)) is disabled$/ @Then /^the "(?P<select>(?:[^"]|\\")*)" (?P<type>(radio)) is disabled$/

File

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

Class

FeatureContext
Features context.

Code

public function assertFieldIsDisabled($select, $type) {
  switch ($type) {
    case 'button':
      $element = $this
        ->getSession()
        ->getPage()
        ->findButton($select);
      break;
    case 'field':
      $element = $this
        ->getSession()
        ->getPage()
        ->findField($select);
      break;
    case 'radio':
      $element = $this
        ->getSession()
        ->getPage()
        ->find('named', array(
        'radio',
        $this
          ->getSession()
          ->getSelectorsHandler()
          ->xpathLiteral($select),
      ));
      break;
  }
  if (!isset($element) || !$element) {
    throw new \RuntimeException(sprintf("The %s '%s' was not found", $type, $select));
  }
  $disabled = $element
    ->getAttribute('disabled');
  if (!$disabled) {
    throw new \RuntimeException(sprintf('The %s "%s" is enabled, but disabled expected.', $type, $select));
  }
}