You are here

public function TestSubContext::assertRegionElementText in Panopoly 8.2

Same name and namespace in other branches
  1. 7 modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc \TestSubContext::assertRegionElementText()

Tests for element content in region.

@Then I should see :text in the :tag element in the :region region

File

modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc, line 754
Provide Behat step-definitions for generic Panopoly tests.

Class

TestSubContext
Behat sub-context for Panopoly.

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()));
  }
}