Unverified Commit 3f42b03b authored by alexpott's avatar alexpott

Issue #2961285 by pavlosdan, hchonov, borisson_: Entity query condition count is faulty

(cherry picked from commit a4208fd3)
parent 1a25e7f2
......@@ -65,7 +65,7 @@ public function getConjunction() {
* {@inheritdoc}
*/
public function count() {
return count($this->conditions) - 1;
return count($this->conditions);
}
/**
......
......@@ -19,8 +19,7 @@ public function getConjunction();
* Implements \Countable::count().
*
* 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
* conjunction.
* size of its conditional array.
*/
public function count();
......
......@@ -556,6 +556,31 @@ public function testNestedConditionGroups() {
$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.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment