Skip to content
Browse files

Zend\Paginator

- reorganized the Mock setup for getItems and count tests to work
  • Loading branch information...
1 parent fb50025 commit e04fb2a3334900e3ae4c318509b9c145fd80dd12 @ralphschindler committed Jun 12, 2013
Showing with 12 additions and 9 deletions.
  1. +12 −9 tests/ZendTest/Paginator/Adapter/DbSelectTest.php
View
21 tests/ZendTest/Paginator/Adapter/DbSelectTest.php
@@ -39,14 +39,17 @@ class DbSelectTest extends \PHPUnit_Framework_TestCase
public function setup()
{
+ $mockResult = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface');
+ $this->mockResult = $mockResult;
+
$mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface');
$this->mockStatement = $mockStatement;
- $mockResult = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface');
+ $this->mockStatement->expects($this->any())->method('execute')->will($this->returnValue($this->mockResult));
$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'));
$mockAdapter = $this->getMockForAbstractClass(
@@ -59,10 +62,15 @@ public function setup()
array('prepareStatementForSqlObject', 'execute'),
array($mockAdapter)
);
-
$this->mockSql = $mockSql;
+ $this->mockSql->expects($this->once())
+ ->method('prepareStatementForSqlObject')
+ ->with($this->isInstanceOf('Zend\Db\Sql\Select'))
+ ->will($this->returnValue($this->mockStatement));
+
+
$this->mockSelect = $this->getMock('Zend\Db\Sql\Select');
- $this->mockResult = $mockResult;
+
$this->dbSelect = new DbSelect($this->mockSelect, $mockSql);
}
@@ -76,11 +84,6 @@ public function testGetItems()
public function testCount()
{
- $this->mockSql->expects($this->once())
- ->method('prepareStatementForSqlObject')
- ->with($this->isInstanceOf('Zend\Db\Sql\Select'))
- ->will($this->returnValue($this->mockStatement));
- $this->mockSql->expects($this->any())->method('execute')->will($this->returnValue($this->mockResult));
$this->mockResult->expects($this->once())->method('current')->will($this->returnValue(array('c' => 5)));
$this->mockSelect->expects($this->exactly(3))->method('reset'); // called for columns, limit, offset, order

0 comments on commit e04fb2a

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