Index: tests/Zend/Paginator/Adapter/IteratorTest.php =================================================================== --- tests/Zend/Paginator/Adapter/IteratorTest.php (revision 21071) +++ tests/Zend/Paginator/Adapter/IteratorTest.php (working copy) @@ -128,4 +128,13 @@ $this->assertTrue( ($items->getInnerIterator() == $innerIterator), 'getItems has to be serializable to use caching'); } + /** + * @group ZF-4151 + */ + public function testEmptySet() { + $iterator = new ArrayIterator(array()); + $this->_adapter = new Zend_Paginator_Adapter_Iterator($iterator); + $actual = $this->_adapter->getItems(0, 10); + $this->assertEquals(array(), $actual); + } } Index: tests/Zend/Paginator/Adapter/NullTest.php =================================================================== --- tests/Zend/Paginator/Adapter/NullTest.php (revision 21071) +++ tests/Zend/Paginator/Adapter/NullTest.php (working copy) @@ -101,4 +101,22 @@ $this->assertEquals(4, $pages->currentItemCount); $this->assertEquals(19, $pages->lastItemNumber); } + + /** + * @group ZF-4151 + */ + public function testEmptySet() { + $this->_adapter = new Zend_Paginator_Adapter_Null(0); + $actual = $this->_adapter->getItems(0, 10); + $this->assertEquals(array(), $actual); + } + + /** + * Verify that the fix for ZF-4151 doesn't create an OBO error + */ + public function testSetOfOne() { + $this->_adapter = new Zend_Paginator_Adapter_Null(1); + $actual = $this->_adapter->getItems(0, 10); + $this->assertEquals(array_fill(0, 1, null), $actual); + } } Index: tests/Zend/Paginator/Adapter/ArrayTest.php =================================================================== --- tests/Zend/Paginator/Adapter/ArrayTest.php (revision 21071) +++ tests/Zend/Paginator/Adapter/ArrayTest.php (working copy) @@ -80,4 +80,14 @@ { $this->assertEquals(101, $this->_adapter->count()); } + + + /** + * @group ZF-4151 + */ + public function testEmptySet() { + $this->_adapter = new Zend_Paginator_Adapter_Array(array()); + $actual = $this->_adapter->getItems(0, 10); + $this->assertEquals(array(), $actual); + } } Index: library/Zend/Paginator/Adapter/Null.php =================================================================== --- library/Zend/Paginator/Adapter/Null.php (revision 21071) +++ library/Zend/Paginator/Adapter/Null.php (working copy) @@ -58,7 +58,7 @@ */ public function getItems($offset, $itemCountPerPage) { - if ($offset > $this->count()) { + if ($offset >= $this->count()) { return array(); }