Skip to content
This repository has been archived by the owner on May 1, 2019. It is now read-only.

Commit

Permalink
Enhancement: Assert pagination() finds in name and description
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Feb 18, 2015
1 parent 17303a9 commit bf8cc2c
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions module/ZfModule/test/ZfModuleTest/Integration/Mapper/ModuleTest.php
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;
}
}

0 comments on commit bf8cc2c

Please sign in to comment.