예제 #1
0
 public static function create($field, $value)
 {
     if (is_scalar($value)) {
         $value = CustomLikeExpression::create($value);
     }
     return parent::create($field, $value);
 }
 public function testAssemble()
 {
     $predicate = new NotLikePredicate();
     $predicate->setField('field');
     $this->assertEquals('field NOT LIKE NULL', QueryAssembler::stringify($predicate));
     $predicate->setExpression(CustomLikeExpression::create(1));
     $this->assertEquals('field NOT LIKE 1', QueryAssembler::stringify($predicate));
     $predicate->setExpression(CustomLikeExpression::create('1'));
     $this->assertEquals('field NOT LIKE "1"', QueryAssembler::stringify($predicate));
     $predicate->setExpression(CustomLikeExpression::create('abc'));
     $this->assertEquals('field NOT LIKE "abc"', QueryAssembler::stringify($predicate));
     $predicate->setExpression(EndsWithExpression::create('abc'));
     $this->assertEquals('field NOT LIKE "%abc"', QueryAssembler::stringify($predicate));
     $predicate->setExpression(ContainsExpression::create('abc'));
     $this->assertEquals('field NOT LIKE "%abc%"', QueryAssembler::stringify($predicate));
     $predicate->setExpression(StartsWithExpression::create('abc'));
     $this->assertEquals('field NOT LIKE "abc%"', QueryAssembler::stringify($predicate));
     $predicate->setExpression(CustomLikeExpression::create('a%bc'));
     $this->assertEquals('field NOT LIKE "a%bc"', QueryAssembler::stringify($predicate));
 }