Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'hotfix/5775'

* hotfix/5775:
  Added unit tests for Zend\Db\Sql's Predicate factory for notLike() CS Fixes
  Update Predicate.php
  • Loading branch information
ralphschindler committed Feb 28, 2014
2 parents 026e47b + 9cf3018 commit 53c4d2f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions library/Zend/Db/Sql/Predicate/Predicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,24 @@ public function like($identifier, $like)

return $this;
}
/**
* Create "notLike" predicate
*
* Utilizes In predicate
*
* @param string $identifier
* @param string $notLike
* @return Predicate
*/
public function notLike($identifier, $notLike)
{
$this->addPredicate(
new NotLike($identifier, $notLike),
($this->nextPredicateCombineOperator) ? : $this->defaultCombination
);
$this->nextPredicateCombineOperator = null;
return $this;
}

/**
* Create an expression, with parameter placeholders
Expand Down
10 changes: 10 additions & 0 deletions tests/ZendTest/Db/Sql/Predicate/PredicateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public function testLikeCreatesLikePredicate()
$this->assertContains(array('foo.bar', 'bar%'), $parts[0]);
}

public function testNotLikeCreatesLikePredicate()
{
$predicate = new Predicate();
$predicate->notLike('foo.bar', 'bar%');
$parts = $predicate->getExpressionData();
$this->assertEquals(1, count($parts));
$this->assertContains('%1$s NOT LIKE %2$s', $parts[0]);
$this->assertContains(array('foo.bar', 'bar%'), $parts[0]);
}

public function testLiteralCreatesLiteralPredicate()
{
$predicate = new Predicate();
Expand Down

0 comments on commit 53c4d2f

Please sign in to comment.