You are here

protected function EntityQueryAggregateTest::assertResults in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::assertResults()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::assertResults()

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

Parameters

array $expected: An array of the expected results.

3 calls to EntityQueryAggregateTest::assertResults()
EntityQueryAggregateTest::assertSortedResults in core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php
Asserts the results as expected regardless of order in rows.
EntityQueryAggregateTest::testAggregation in core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php
Test aggregation support.
EntityQueryAggregateTest::testRepeatedExecution in core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php
Tests preparing a query and executing twice.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php, line 582

Class

EntityQueryAggregateTest
Tests the Entity Query Aggregation API.

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function assertResults($expected, $sorted = FALSE) {
  $found = TRUE;
  $expected_keys = array_keys($expected);
  foreach ($this->queryResult as $key => $row) {
    $keys = $sorted ? [
      $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', [
    '!expected' => print_r($expected, TRUE),
    '!found' => print_r($this->queryResult, TRUE),
  ]));
}