예제 #1
0
 public function testAssemble()
 {
     $clause = new WhereClause();
     $eq = new EqualPredicate();
     $eq->setField('one')->setExpression((new StringExpression())->setValue('val'));
     $clause->addPredicate($eq);
     $this->assertEquals('WHERE one = "val"', QueryAssembler::stringify($clause));
     $eq = new GreaterThanPredicate();
     $eq->setField('two')->setExpression((new NumericExpression())->setValue(5));
     $clause->addPredicate($eq);
     $this->assertEquals('WHERE one = "val" AND two > 5', QueryAssembler::stringify($clause));
 }
 public function testAssemble()
 {
     $predicate = new GreaterThanPredicate();
     $predicate->setField('field');
     $this->assertEquals('field > NULL', QueryAssembler::stringify($predicate));
     $predicate->setExpression((new NumericExpression())->setValue(1));
     $this->assertEquals('field > 1', QueryAssembler::stringify($predicate));
     $predicate->setExpression((new NumericExpression())->setValue('1'));
     $this->assertEquals('field > 1', QueryAssembler::stringify($predicate));
     $predicate->setExpression((new StringExpression())->setValue('abc'));
     $this->assertEquals('field > "abc"', QueryAssembler::stringify($predicate));
 }