You are here

public function SocialMinkContext::assertRegionHeading in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::assertRegionHeading()
  2. 8.3 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::assertRegionHeading()
  3. 8.4 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::assertRegionHeading()
  4. 8.5 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::assertRegionHeading()
  5. 8.6 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::assertRegionHeading()
  6. 8.7 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::assertRegionHeading()
  7. 8.8 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::assertRegionHeading()
  8. 10.3.x tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::assertRegionHeading()
  9. 10.1.x tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::assertRegionHeading()
  10. 10.2.x tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::assertRegionHeading()

@override MinkContext::assertRegionHeading()

Makes the step case insensitive.

File

tests/behat/features/bootstrap/SocialMinkContext.php, line 28

Class

SocialMinkContext
Defines application features from the specific context.

Namespace

Drupal\social\Behat

Code

public function assertRegionHeading($heading, $region) {
  $regionObj = $this
    ->getRegion($region);
  foreach (array(
    'h1',
    'h2',
    'h3',
    'h4',
    'h5',
    'h6',
  ) as $tag) {
    $elements = $regionObj
      ->findAll('css', $tag);
    if (!empty($elements)) {
      foreach ($elements as $element) {
        if (trim(strtolower($element
          ->getText())) === strtolower($heading)) {
          return;
        }
      }
    }
  }
  throw new \Exception(sprintf('The heading "%s" was not found in the "%s" region on the page %s', $heading, $region, $this
    ->getSession()
    ->getCurrentUrl()));
}