public function TestSubContext::assertRegionElementText in Drupal Commons 7.3
@Then I should see :text in the :tag element in the :region region
File
- tests/
steps/ commons_test.behat.inc, line 404 - Provide Behat step-definitions for generic Commons tests.
Class
Code
public function assertRegionElementText($text, $tag, $region) {
$regionObj = $this
->getRegion($region);
$elements = $regionObj
->findAll('css', $tag);
if (empty($elements)) {
throw new \Exception(sprintf('The element "%s" was not found in the "%s" region on the page %s', $tag, $region, $this
->getSession()
->getCurrentUrl()));
}
$found = FALSE;
foreach ($elements as $element) {
if ($element
->getText() == $text) {
$found = TRUE;
break;
}
}
if (!$found) {
throw new \Exception(sprintf('The text "%s" was not found in the "%s" element in the "%s" region on the page %s', $text, $tag, $region, $this
->getSession()
->getCurrentUrl()));
}
}