protected function EntityQueryTest::assertBundleOrder

1 call to EntityQueryTest::assertBundleOrder()
EntityQueryTest::testTableSort in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
Test tablesort().

File

drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php, line 436
Definition of Drupal\system\Tests\Entity\EntityQueryTest.

Class

EntityQueryTest
Tests the basic Entity API.

Namespace

Drupal\system\Tests\Entity

Code

protected function assertBundleOrder($order) {

  // This loop is for bundle1 entities.
  for ($i = 1; $i <= 15; $i += 2) {
    $ok = TRUE;
    $index1 = array_search($i, $this->queryResults);
    $this
      ->assertNotIdentical($index1, FALSE, "{$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, format_string("{$i} is after all entities in bundle2"));
  }
}