public function EntityQueryTest::testConditionCount in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::testConditionCount()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::testConditionCount()
Tests that condition count returns expected number of conditions.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityQueryTest.php, line 574
Class
- EntityQueryTest
- Tests Entity Query functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testConditionCount() {
// Query for all entities of the first bundle that
// have red as a color AND are triangle shaped.
$query = $this->storage
->getQuery();
// Add an AND condition group with 2 conditions in it.
$and_condition_group = $query
->andConditionGroup()
->condition($this->figures . '.color', 'red')
->condition($this->figures . '.shape', 'triangle');
// We added 2 conditions so count should be 2.
$this
->assertEqual($and_condition_group
->count(), 2);
// Add an OR condition group with 2 conditions in it.
$or_condition_group = $query
->orConditionGroup()
->condition($this->figures . '.color', 'red')
->condition($this->figures . '.shape', 'triangle');
// We added 2 conditions so count should be 2.
$this
->assertEqual($or_condition_group
->count(), 2);
}