Skip to content

Commit

Permalink
Merge branch 'postalservice14-hotfix/ZF2-421'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Schindler committed Jul 26, 2012
2 parents 9c7583b + 059a37d commit 37b25cf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions library/Zend/Db/Sql/Predicate/Predicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ public function equalTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $right
return $this;
}

/**
* Create "Not Equal To" predicate
*
* Utilizes Operator predicate
*
* @param scalar $left
* @param scalar $right
* @param TYPE_IDENTIFIER|TYPE_VALUE $leftType
* @param TYPE_IDENTIFIER|TYPE_VALUE $rightType
* @return Predicate
*/
public function notEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE)
{
$this->addPredicate(
new Operator($left, Operator::OPERATOR_NOT_EQUAL_TO, $right, $leftType, $rightType),
($this->nextPredicateCombineOperator) ?: $this->defaultCombination
);
$this->nextPredicateCombineOperator = null;

return $this;
}

/**
* Create "Less Than" predicate
*
Expand Down
11 changes: 11 additions & 0 deletions tests/Zend/Db/Sql/Predicate/PredicateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ public function testEqualToCreatesOperatorPredicate()
$this->assertContains(array('foo.bar', 'bar'), $parts[0]);
}

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


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

0 comments on commit 37b25cf

Please sign in to comment.