protected function WeightTest::assertOrderInPage in Weight 8.3
Asserts that several pieces of markup are in a given order in the page.
@todo Remove this once https://www.drupal.org/node/2817657 is committed.
Parameters
string[] $items: An ordered list of strings.
Throws
\Behat\Mink\Exception\ExpectationException When any of the given string is not found.
1 call to WeightTest::assertOrderInPage()
- WeightTest::testWeightSelectorBase in tests/
src/ FunctionalJavascript/ WeightTest.php - Test basic weight ordering.
File
- tests/
src/ FunctionalJavascript/ WeightTest.php, line 298
Class
- WeightTest
- Test basic functionality of weight.
Namespace
Drupal\Tests\weight\FunctionalJavascriptCode
protected function assertOrderInPage(array $items) {
$session = $this
->getSession();
$text = $session
->getPage()
->getHtml();
$strings = [];
foreach ($items as $item) {
if (($pos = strpos($text, $item)) === FALSE) {
throw new ExpectationException("Cannot find '{$item}' in the page", $session
->getDriver());
}
$strings[$pos] = $item;
}
ksort($strings);
$ordered = implode(', ', array_map(function ($item) {
return "'{$item}'";
}, $items));
$this
->assertSame($items, array_values($strings), "Found strings, ordered as: {$ordered}.");
}