function TableDragTest::assertOrder

Same name in other branches
  1. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::assertOrder()
  2. 10 core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::assertOrder()
  3. 11.x core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::assertOrder()

Asserts that several pieces of markup are in a given order in the page.

@todo Remove this and use the WebAssert method when #2817657 is done.

@internal

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 TableDragTest::assertOrder()
TableDragTest::testDragAndDrop in core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php
Tests draggable table drag'n'drop.

File

core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php, line 329

Class

TableDragTest
Tests draggable table.

Namespace

Drupal\FunctionalJavascriptTests\TableDrag

Code

protected function assertOrder(array $items) : void {
    $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);
    $this->assertSame($items, array_values($strings), "Strings found on the page but incorrectly ordered.");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.