function EntityQueryTest::assertBundleOrder

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::assertBundleOrder()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::assertBundleOrder()
  3. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::assertBundleOrder()

@internal

1 call to EntityQueryTest::assertBundleOrder()
EntityQueryTest::testTableSort in core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php
Tests tablesort().

File

core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php, line 765

Class

EntityQueryTest
Tests Entity Query functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function assertBundleOrder(string $order) : void {
    // This loop is for bundle1 entities.
    for ($i = 1; $i <= 15; $i += 2) {
        $ok = TRUE;
        $index1 = array_search($i, $this->queryResults);
        $this->assertNotFalse($index1, "{$i} found at {$index1}.");
        // This loop is for bundle2 entities.
        for ($j = 2; $j <= 15; $j += 2) {
            if ($ok) {
                if ($order == 'asc') {
                    $ok = $index1 > array_search($j, $this->queryResults);
                }
                else {
                    $ok = $index1 < array_search($j, $this->queryResults);
                }
            }
        }
        $this->assertTrue($ok, "{$i} is after all entities in bundle2");
    }
}

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