public function EntityQueryTest::testNestedConditionGroups in Drupal 8
Same name and namespace in other branches
- 9 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 546
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();
$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);
}