Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add unit test and improve existing

Add unit test and improve existing
  • Loading branch information...
commit 69818cb4691e3c9ff70a1502e9f995f8c9c4a290 1 parent 1774c44
@blanchonvincent blanchonvincent authored
Showing with 33 additions and 3 deletions.
  1. +33 −3 tests/ZendTest/Paginator/FactoryTest.php
View
36 tests/ZendTest/Paginator/FactoryTest.php
@@ -22,10 +22,34 @@
*/
class FactoryTest extends \PHPUnit_Framework_TestCase
{
+ /** @var \PHPUnit_Framework_MockObject_MockObject */
+ protected $mockSelect;
+
+ protected $mockAdapter;
+
+ protected function setUp()
+ {
+ $this->mockSelect = $this->getMock('Zend\Db\Sql\Select');
+
+ $mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface');
+ $mockResult = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface');
+
+ $mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface');
+ $mockDriver->expects($this->any())->method('createStatement')->will($this->returnValue($mockStatement));
+ $mockStatement->expects($this->any())->method('execute')->will($this->returnValue($mockResult));
+ $mockPlatform = $this->getMock('Zend\Db\Adapter\Platform\PlatformInterface');
+ $mockPlatform->expects($this->any())->method('getName')->will($this->returnValue('platform'));
+
+ $this->mockAdapter = $this->getMockForAbstractClass(
+ 'Zend\Db\Adapter\Adapter',
+ array($mockDriver, $mockPlatform)
+ );
+ }
+
public function testCanFactoryPaginatorWithStringAdapterObject()
{
$datas = array(1, 2, 3);
- $paginator = Paginator\Factory::Factory($datas, new Adapter\ArrayAdapter($datas));
+ $paginator = Paginator\Factory::factory($datas, new Adapter\ArrayAdapter($datas));
$this->assertInstanceOf('Zend\Paginator\Adapter\ArrayAdapter', $paginator->getAdapter());
$this->assertEquals(count($datas), $paginator->getCurrentItemCount());
}
@@ -33,14 +57,20 @@ public function testCanFactoryPaginatorWithStringAdapterObject()
public function testCanFactoryPaginatorWithStringAdapterName()
{
$datas = array(1, 2, 3);
- $paginator = Paginator\Factory::Factory($datas, 'array');
+ $paginator = Paginator\Factory::factory($datas, 'array');
$this->assertInstanceOf('Zend\Paginator\Adapter\ArrayAdapter', $paginator->getAdapter());
$this->assertEquals(count($datas), $paginator->getCurrentItemCount());
}
public function testCanFactoryPaginatorWithStringAdapterAggregate()
{
- $paginator = Paginator\Factory::Factory(null, new TestArrayAggregate);
+ $paginator = Paginator\Factory::factory(null, new TestArrayAggregate);
$this->assertInstanceOf('Zend\Paginator\Adapter\ArrayAdapter', $paginator->getAdapter());
}
+
+ public function testCanFactoryPaginatorWithDbSelect()
+ {
+ $paginator = Paginator\Factory::factory(array($this->mockSelect, $this->mockAdapter), 'dbselect');
+ $this->assertInstanceOf('Zend\Paginator\Adapter\DbSelect', $paginator->getAdapter());
+ }
}

0 comments on commit 69818cb

Please sign in to comment.
Something went wrong with that request. Please try again.