You are here

public function TestSubContext::assertNotRegionElementTextAttribute in Drupal Commons 7.3

@Then I should not see :text in the :tag element with the :attribute attribute set to :value in the :region region

File

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

Class

TestSubContext

Code

public function assertNotRegionElementTextAttribute($text, $tag, $attribute, $value, $region) {
  $regionObj = $this
    ->getRegion($region);
  $elements = $regionObj
    ->findAll('css', $tag);
  if (!empty($elements)) {
    foreach ($elements as $element) {
      if ($element
        ->getText() == $text) {
        $attr = $element
          ->getAttribute($attribute);
        if (!empty($attr) && strpos($attr, "{$value}") !== FALSE) {
          throw new \Exception(sprintf('The text "%s" was found in the "%s" element with the "%s" attribute set to "%s" in the "%s" region on the page %s', $text, $tag, $attribute, $value, $region, $this
            ->getSession()
            ->getCurrentUrl()));
        }
      }
    }
  }
}