public function FeatureContext::shouldPrecedeForTheQuery in Open Social 8.4
Same name and namespace in other branches
- 8.9 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::shouldPrecedeForTheQuery()
- 8.3 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::shouldPrecedeForTheQuery()
- 8.5 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::shouldPrecedeForTheQuery()
- 8.6 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::shouldPrecedeForTheQuery()
- 8.7 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::shouldPrecedeForTheQuery()
- 8.8 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::shouldPrecedeForTheQuery()
- 10.3.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::shouldPrecedeForTheQuery()
- 10.0.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::shouldPrecedeForTheQuery()
- 10.1.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::shouldPrecedeForTheQuery()
- 10.2.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::shouldPrecedeForTheQuery()
@Then :textBefore should precede :textAfter for the query :cssQuery
File
- tests/
behat/ features/ bootstrap/ FeatureContext.php, line 451
Class
- FeatureContext
- Defines application features from the specific context.
Namespace
Drupal\social\BehatCode
public function shouldPrecedeForTheQuery($textBefore, $textAfter, $cssQuery) {
$elements = $this
->getSession()
->getPage()
->findAll('css', $cssQuery);
$items = array_map(function ($element) {
return $element
->getText();
}, $elements);
$checkBefore = $textBefore;
$checkAfter = $textAfter;
foreach ($items as $item) {
if (strpos($item, $textBefore) !== FALSE) {
$checkBefore = $item;
}
elseif (strpos($item, $textAfter) !== FALSE) {
$checkAfter = $item;
}
}
Assert::assertGreaterThan(array_search($checkBefore, $items), array_search($checkAfter, $items), "{$textBefore} does not proceed {$textAfter}");
}