This repository has been archived by the owner on May 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Assert pagination() finds in name and description
- Loading branch information
1 parent
17303a9
commit bf8cc2c
Showing
1 changed file
with
101 additions
and
0 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
module/ZfModule/test/ZfModuleTest/Integration/Mapper/ModuleTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
|
||
namespace ZfModuleTest\Integration\Mapper; | ||
|
||
use ApplicationTest\Integration\Util\Bootstrap; | ||
use PHPUnit_Framework_TestCase; | ||
use Zend\Db; | ||
use ZfModule\Entity; | ||
use ZfModule\Mapper; | ||
|
||
class ModuleTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Mapper\Module | ||
*/ | ||
private $mapper; | ||
|
||
/** | ||
* @var Db\Adapter\Driver\ConnectionInterface | ||
*/ | ||
private $connection; | ||
|
||
protected function setUp() | ||
{ | ||
$serviceManager = Bootstrap::getServiceManager(); | ||
|
||
$this->mapper = $serviceManager->get(Mapper\Module::class); | ||
|
||
/* @var Db\Adapter\Adapter $database */ | ||
$database = $serviceManager->get('zfcuser_zend_db_adapter'); | ||
|
||
$this->connection = $database->getDriver()->getConnection(); | ||
$this->connection->beginTransaction(); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
$this->connection->rollback(); | ||
|
||
unset($this->mapper); | ||
unset($this->connection); | ||
} | ||
|
||
/** | ||
* @dataProvider providerProperties | ||
* | ||
* @param $property | ||
*/ | ||
public function testPaginationFindsInProperty($property) | ||
{ | ||
$value = 'foo bar baz'; | ||
$query = 'bar'; | ||
|
||
$module = $this->module(); | ||
|
||
$setter = 'set' . ucfirst($property); | ||
|
||
$module->{$setter}($value); | ||
|
||
$this->mapper->insert($module); | ||
|
||
$paginator = $this->mapper->pagination(1, 100, $query); | ||
|
||
$this->assertSame(1, $paginator->getTotalItemCount()); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function providerProperties() | ||
{ | ||
return [ | ||
[ | ||
'name', | ||
], | ||
[ | ||
'description', | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @return Entity\Module | ||
*/ | ||
private function module() | ||
{ | ||
static $id = 1; | ||
|
||
$module = new Entity\Module(); | ||
|
||
$module->setId($id); | ||
$module->setName(''); | ||
$module->setOwner(''); | ||
$module->setDescription(''); | ||
$module->setUrl(''); | ||
|
||
$id++; | ||
|
||
return $module; | ||
} | ||
} |