function ConfigEntityQueryTest::testCount
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php \Drupal\KernelTests\Core\Entity\ConfigEntityQueryTest::testCount()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php \Drupal\KernelTests\Core\Entity\ConfigEntityQueryTest::testCount()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php \Drupal\KernelTests\Core\Entity\ConfigEntityQueryTest::testCount()
Tests count query.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ ConfigEntityQueryTest.php, line 431
Class
- ConfigEntityQueryTest
- Tests Config Entity Query functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testCount() : void {
// Test count on no conditions.
$count = $this->entityStorage
->getQuery()
->count()
->execute();
$this->assertCount($count, $this->entities);
// Test count on a complex query.
$query = $this->entityStorage
->getQuery('OR');
$and_condition_1 = $query->andConditionGroup()
->condition('id', 1)
->condition('label', $this->entities[0]->label);
$and_condition_2 = $query->andConditionGroup()
->condition('id', '2')
->condition('label', $this->entities[1]->label);
$count = $query->condition($and_condition_1)
->condition($and_condition_2)
->count()
->execute();
$this->assertSame(2, $count);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.