You are here

public function TestSubContext::assertRegionMatchesText in Panopoly 8.2

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

Asserts that the region contains text matching specified pattern.

@Then I should see text matching :pattern in the :region region

File

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

Class

TestSubContext
Behat sub-context for Panopoly.

Code

public function assertRegionMatchesText($pattern, $region) {
  $regionObj = $this
    ->getRegion($region);

  // Find the text within the region.
  $regionText = $regionObj
    ->getText();
  if (!preg_match($pattern, $regionText)) {
    throw new \Exception(sprintf("No text matching '%s' was found in the region '%s' on the page %s", $pattern, $region, $this
      ->getSession()
      ->getCurrentUrl()));
  }
}