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)); }
public function testHelper() { $field = new Types\String('burger'); $equal = new Conditions\Equal($field, 'poney'); $different = new Conditions\Different($field, 'poney'); $like = new Conditions\Like($field, 'poney'); $notLike = new Conditions\NotLike($field, 'poney'); $greater = new Conditions\Greater($field, 'poney'); $greaterOrEqual = new Conditions\GreaterOrEqual($field, 'poney'); $lower = new Conditions\Lower($field, 'poney'); $lowerOrEqual = new Conditions\LowerOrEqual($field, 'poney'); $between = new Conditions\Between($field, 42, 666); $isNull = new Conditions\IsNull($field); $isNotNull = new Conditions\IsNotNull($field); $in = new Conditions\In($field, array('poney', 'unicorn')); $notIn = new Conditions\NotIn($field, array('poney', 'unicorn')); $conditionViaHelper = $field->equal('poney'); $this->assertEquals($equal->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->different('poney'); $this->assertEquals($different->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->like('poney'); $this->assertEquals($like->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->notLike('poney'); $this->assertEquals($notLike->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->greaterThan('poney'); $this->assertEquals($greater->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->greaterOrEqualThan('poney'); $this->assertEquals($greaterOrEqual->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->lowerThan('poney'); $this->assertEquals($lower->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->lowerOrEqualThan('poney'); $this->assertEquals($lowerOrEqual->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->between(42, 666); $this->assertEquals($between->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->isNull(); $this->assertEquals($isNull->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->isNotNull(); $this->assertEquals($isNotNull->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->in(array('poney', 'unicorn')); $this->assertEquals($in->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); $conditionViaHelper = $field->notIn(array('poney', 'unicorn')); $this->assertEquals($notIn->toString($this->escaper), $conditionViaHelper->toString($this->escaper)); }
/** * @dataProvider providerTestFieldGreaterThanField */ public function testFieldGreaterThanField($expected, $columnLeft, $columnRight) { $condition = new Conditions\Greater($columnLeft, $columnRight); $this->assertSame($expected, $condition->toString($this->escaper)); }