function EntityQueryAggregateTest::assertResults
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::assertResults()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::assertResults()
- 11.x 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.
@internal
Parameters
array $expected: An array of the expected results.
bool $sorted: (optiOnal) Whether the array keys of the expected are sorted, defaults to FALSE.
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 - Tests 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 635
Class
- EntityQueryAggregateTest
- Tests the Entity Query Aggregation API.
Namespace
Drupal\KernelTests\Core\EntityCode
protected function assertResults(array $expected, bool $sorted = FALSE) : void {
$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;
}
$this->assertTrue($found, strtr('!expected expected, !found found', [
'!expected' => print_r($expected, TRUE),
'!found' => print_r($this->queryResult, TRUE),
]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.