You are here

public function TestSubContext::assertAltRegion in Drupal Commons 7.3

@Then /^I should see the image alt "(?P<text>(?:[^"]|\\")*)" in the "(?P<region>[^"]*)" region$/

NOTE: We specify a regex to allow escaped quotes in the alt text.

File

tests/steps/commons_test.behat.inc, line 524
Provide Behat step-definitions for generic Commons tests.

Class

TestSubContext

Code

public function assertAltRegion($text, $region) {
  $regionObj = $this
    ->getRegion($region);
  $element = $regionObj
    ->find('css', 'img');
  $tmp = $element
    ->getAttribute('alt');
  if ($text == $tmp) {
    $result = $text;
  }
  if (empty($result)) {
    throw new \Exception(sprintf('No alt text matching "%s" in the "%s" region on the page %s', $text, $region, $this
      ->getSession()
      ->getCurrentUrl()));
  }
}