From 4926b50737534e95ef7540c0ab4bfd7878f13579 Mon Sep 17 00:00:00 2001 From: Emmanuel Belair Date: Tue, 15 Oct 2013 15:39:14 +0200 Subject: [PATCH] Add Not Like Predicate --- library/Zend/Db/Sql/Predicate/NotLike.php | 16 +++++ .../ZendTest/Db/Sql/Predicate/NotLikeTest.php | 64 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 library/Zend/Db/Sql/Predicate/NotLike.php create mode 100644 tests/ZendTest/Db/Sql/Predicate/NotLikeTest.php diff --git a/library/Zend/Db/Sql/Predicate/NotLike.php b/library/Zend/Db/Sql/Predicate/NotLike.php new file mode 100644 index 00000000000..b3963d83914 --- /dev/null +++ b/library/Zend/Db/Sql/Predicate/NotLike.php @@ -0,0 +1,16 @@ +assertEquals('', $notLike->getIdentifier()); + $this->assertEquals('', $notLike->getLike()); + } + + public function testConstructWithArgs() + { + $notLike = new NotLike('bar', 'Foo%'); + $this->assertEquals('bar', $notLike->getIdentifier()); + $this->assertEquals('Foo%', $notLike->getLike()); + } + + public function testAccessorsMutators() + { + $notLike = new NotLike(); + $notLike->setIdentifier('bar'); + $this->assertEquals('bar', $notLike->getIdentifier()); + $notLike->setLike('foo%'); + $this->assertEquals('foo%', $notLike->getLike()); + $notLike->setSpecification('target = target'); + $this->assertEquals('target = target', $notLike->getSpecification()); + } + + public function testGetExpressionData() + { + $notLike = new NotLike('bar', 'Foo%'); + $this->assertEquals( + array( + array( + '%1$s NOT LIKE %2$s', + array('bar', 'Foo%'), + array($notLike::TYPE_IDENTIFIER, $notLike::TYPE_VALUE) + ) + ), + $notLike->getExpressionData() + ); + } + + public function testInstanceOfPerSetters() + { + $notLike = new NotLike(); + $this->assertInstanceOf('Zend\Db\Sql\Predicate\Like', $notLike->setIdentifier('bar')); + $this->assertInstanceOf('Zend\Db\Sql\Predicate\Like', $notLike->setSpecification('%1$s NOT LIKE %2$s')); + $this->assertInstanceOf('Zend\Db\Sql\Predicate\Like', $notLike->setLike('foo%')); + } +}