Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Add Not Like Predicate #5287

Merged
merged 1 commit into from Oct 21, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions library/Zend/Db/Sql/Predicate/NotLike.php
@@ -0,0 +1,16 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Db\Sql\Predicate;


class NotLike extends Like
{
protected $specification = '%1$s NOT LIKE %2$s';
}
64 changes: 64 additions & 0 deletions tests/ZendTest/Db/Sql/Predicate/NotLikeTest.php
@@ -0,0 +1,64 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\Db\Sql\Predicate;


use Zend\Db\Sql\Predicate\NotLike;

class NotLikeTest extends \PHPUnit_Framework_TestCase
{
public function testConstructEmptyArgs()
{
$notLike = new NotLike();
$this->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%'));
}
}