You are here

protected function EntityQueryAggregateTest::assertResults in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php \Drupal\system\Tests\Entity\EntityQueryAggregateTest::assertResults()

Asserts the results as expected regardless of order between and in rows.

Parameters

array $expected: An array of the expected results.

2 calls to EntityQueryAggregateTest::assertResults()
EntityQueryAggregateTest::assertSortedResults in core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php
Asserts the results as expected regardless of order in rows.
EntityQueryAggregateTest::testAggregation in core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php
Test aggregation support.

File

core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php, line 559
Contains \Drupal\system\Tests\Entity\EntityQueryAggregateTest.

Class

EntityQueryAggregateTest
Tests the Entity Query Aggregation API.

Namespace

Drupal\system\Tests\Entity

Code

protected function assertResults($expected, $sorted = FALSE) {
  $found = TRUE;
  $expected_keys = array_keys($expected);
  foreach ($this->queryResult as $key => $row) {
    $keys = $sorted ? array(
      $key,
    ) : $expected_keys;
    foreach ($keys as $key) {
      $expected_row = $expected[$key];
      if (!array_diff_assoc($row, $expected_row) && !array_diff_assoc($expected_row, $row)) {
        continue 2;
      }
    }
    $found = FALSE;
    break;
  }
  return $this
    ->assertTrue($found, strtr('!expected expected, !found found', array(
    '!expected' => print_r($expected, TRUE),
    '!found' => print_r($this->queryResult, TRUE),
  )));
}