public function testConditionIsEmpty() { $condition = new Conditions\NullCondition(); $this->assertTrue($condition->isEmpty()); $condition = (new Conditions\NullCondition())->and(new Conditions\Equal(new Types\Integer('response'), 42)); $this->assertFalse($condition->isEmpty()); $condition = (new Conditions\Equal(new Types\Integer('response'), 42))->and(new Conditions\NullCondition()); $this->assertFalse($condition->isEmpty()); }
public function providerTestHaving() { $nullCondition = new Conditions\NullCondition(); $simpleCondition = new Conditions\Greater(new Types\Integer('score'), 42); $compositeCondition1 = $simpleCondition->and((new Conditions\Equal(new Types\String('type'), 'burger'))->or(new Conditions\Greater(new Types\Integer('score'), 1337))); $compositeCondition2 = $nullCondition->and($simpleCondition)->and((new Conditions\Equal(new Types\String('type'), 'burger'))->or(new Conditions\Greater(new Types\Integer('score'), 1337))); $nullAndCompositeCondition = $nullCondition->and((new Conditions\Equal(new Types\String('type'), 'burger'))->or(new Conditions\Greater(new Types\Integer('score'), 1337))); $nullCompositeCondition = $nullCondition->and($nullCondition->and($nullCondition->or($nullCondition))); return array('null condition' => array('', $nullCondition), 'null composite condition' => array('', $nullCompositeCondition), 'simple condition' => array('HAVING score > 42', $simpleCondition), 'composite condition 1' => array("HAVING score > 42 AND (type = 'burger' OR score > 1337)", $compositeCondition1), 'nullCondition and simple condition and composite condition 2' => array("HAVING (score > 42) AND (type = 'burger' OR score > 1337)", $compositeCondition2)); }