public function TestSubContext::assertAltRegion in Panopoly 7
Same name and namespace in other branches
- 8.2 modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc \TestSubContext::assertAltRegion()
@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
- modules/
panopoly/ panopoly_test/ behat/ steps/ panopoly_test.behat.inc, line 931 - Provide Behat step-definitions for generic Panopoly tests.
Class
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()));
}
}