function EntityQueryTest::testNestedConditionGroups
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::testNestedConditionGroups()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::testNestedConditionGroups()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::testNestedConditionGroups()
Tests that nested condition groups work as expected.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityQueryTest.php, line 585
Class
- EntityQueryTest
- Tests Entity Query functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testNestedConditionGroups() {
// Query for all entities of the first bundle that have either a red
// triangle as a figure or the Turkish greeting as a greeting.
$query = $this->storage
->getQuery()
->accessCheck(FALSE);
$first_and = $query->andConditionGroup()
->condition($this->figures . '.color', 'red')
->condition($this->figures . '.shape', 'triangle');
$second_and = $query->andConditionGroup()
->condition($this->greetings . '.value', 'merhaba')
->condition($this->greetings . '.format', 'format-tr');
$or = $query->orConditionGroup()
->condition($first_and)
->condition($second_and);
$this->queryResults = $query->condition($or)
->condition('type', reset($this->bundles))
->sort('id')
->execute();
$this->assertResult(4, 6, 12, 14);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.