addConditionsToQuery adds "=" by default
This commit is contained in:
parent
804694c0cc
commit
f6792e5053
@ -21,10 +21,9 @@ class Utils {
|
||||
|
||||
public function addConditionsToQuery(QueryInterface $query, array $conditions): void {
|
||||
foreach($conditions as $condition) {
|
||||
if (sizeof($condition) != 3) throw new RuntimeException('Utils::addConditionsToQuery needs each condition to consist of 3 strings');
|
||||
$field = $condition[0];
|
||||
$value = $condition[1];
|
||||
$operator = $condition[2];
|
||||
$operator = isset($condition[2]) ? $condition[2] : "=";
|
||||
$query->condition($field, $value, $operator);
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,10 @@ class UtilsTest extends UnitTestCase{
|
||||
->willReturn([$term_entity]);
|
||||
$this->assertEquals($this->utils->getTidByName('foo', 'bar'), 3);
|
||||
}
|
||||
public function testAddConditionToQueryExceptsIfNotGivenArraysOf3Things():void {
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->utils->addConditionsToQuery($this->query, [["1","2"], ["1"]]);
|
||||
public function testAddConditionToQueryAddsEqualsIfNoOperatorProvided():void {
|
||||
$this->query->expects($this->exactly(1))->method('condition')->with("1", "2", "=");
|
||||
$this->utils->addConditionsToQuery($this->query, [["1","2"]]);
|
||||
|
||||
}
|
||||
public function testAddConditionToQueryAddsTheRightAmountOfConditions():void {
|
||||
$this->query->expects($this->exactly(4))->method('condition');
|
||||
|
Reference in New Issue
Block a user