public function ConfigEntityQueryTest::testCount in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php \Drupal\system\Tests\Entity\ConfigEntityQueryTest::testCount()
Tests count query.
File
- core/
modules/ system/ src/ Tests/ Entity/ ConfigEntityQueryTest.php, line 405 - Contains \Drupal\system\Tests\Entity\ConfigEntityQueryTest.
Class
- ConfigEntityQueryTest
- Tests Config Entity Query functionality.
Namespace
Drupal\system\Tests\EntityCode
public function testCount() {
// Test count on no conditions.
$count = $this->factory
->get('config_query_test')
->count()
->execute();
$this
->assertIdentical($count, count($this->entities));
// Test count on a complex query.
$query = $this->factory
->get('config_query_test', '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
->assertIdentical($count, 2);
}