Issue #2961285 by pavlosdan, hchonov, borisson_: Entity query condition count is faulty
parent
c9159d8633
commit
a4208fd3c8
|
@ -65,7 +65,7 @@ abstract class ConditionFundamentals {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function count() {
|
public function count() {
|
||||||
return count($this->conditions) - 1;
|
return count($this->conditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,8 +19,7 @@ interface ConditionInterface {
|
||||||
* Implements \Countable::count().
|
* Implements \Countable::count().
|
||||||
*
|
*
|
||||||
* Returns the size of this conditional. The size of the conditional is the
|
* Returns the size of this conditional. The size of the conditional is the
|
||||||
* size of its conditional array minus one, because one element is the
|
* size of its conditional array.
|
||||||
* conjunction.
|
|
||||||
*/
|
*/
|
||||||
public function count();
|
public function count();
|
||||||
|
|
||||||
|
|
|
@ -556,6 +556,31 @@ class EntityQueryTest extends EntityKernelTestBase {
|
||||||
$this->assertResult(4, 6, 12, 14);
|
$this->assertResult(4, 6, 12, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that condition count returns expected number of conditions.
|
||||||
|
*/
|
||||||
|
public function testConditionCount() {
|
||||||
|
// Query for all entities of the first bundle that
|
||||||
|
// have red as a colour 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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test queries with delta conditions.
|
* Test queries with delta conditions.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue