public function FeatureContext::shouldPrecedeForTheQuery in Open Social 8
Same name and namespace in other branches
- 8.2 tests/behat/features/bootstrap/FeatureContext.php \FeatureContext::shouldPrecedeForTheQuery()
@Then :textBefore should precede :textAfter for the query :cssQuery
File
- tests/
behat/ features/ bootstrap/ FeatureContext.php, line 396
Class
- FeatureContext
- Defines application features from the specific context.
Code
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;
}
}
PHPUnit::assertGreaterThan(array_search($checkBefore, $items), array_search($checkAfter, $items), "{$textBefore} does not proceed {$textAfter}");
}