function EntityQueryAggregateTest::testRepeatedExecution
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::testRepeatedExecution()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::testRepeatedExecution()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::testRepeatedExecution()
Tests preparing a query and executing twice.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityQueryAggregateTest.php, line 594
Class
- EntityQueryAggregateTest
- Tests the Entity Query Aggregation API.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testRepeatedExecution() : void {
$query = $this->entityStorage
->getAggregateQuery()
->accessCheck(FALSE)
->groupBy('user_id');
$this->queryResult = $query->execute();
$this->assertResults([
[
'user_id' => 1,
],
[
'user_id' => 2,
],
[
'user_id' => 3,
],
]);
$entity = $this->entityStorage
->create([
'id' => 7,
'user_id' => 4,
'field_test_1' => 42,
'field_test_2' => 68,
]);
$entity->enforceIsNew();
$entity->save();
$this->queryResult = $query->execute();
$this->assertResults([
[
'user_id' => 1,
],
[
'user_id' => 2,
],
[
'user_id' => 3,
],
[
'user_id' => 4,
],
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.