You are here

public function TestSubContext::assertNotRegionMatchesText in Drupal Commons 7.3

Asserts that the region does not contain text matching specified pattern.

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

File

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

Class

TestSubContext

Code

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

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