--- Zend/PaginatorTest.php (revision 22312) +++ Zend/PaginatorTest.php (working copy) @@ -997,6 +997,31 @@ $p = new Zend_Paginator(array()); } + + public function testCacheWithComplexAdapter() { + require_once 'Zend/Paginator/_files/Zf6989.php'; + require_once 'Zend/Paginator/_files/Zf6989_AdapterSource.php'; + + $adapterSource1 = new Zf6989_AdapterSource(100); + $adapter1 = new Zf6989($adapterSource1); + $paginator1 = new Zend_Paginator($adapter1); + $paginator1 + ->setCurrentPageNumber(1) + ->setItemCountPerPage(2); + $res1 = $paginator1->getCurrentItems(); + + $adapterSource2 = $this->getMock('Zf6989_AdapterSource', array('execute'), array(100)); + $adapterSource2 + ->expects($this->never()) + ->method('execute') + ->will($this->returnValue(array())); + $adapter2 = new Zf6989($adapterSource2); + $paginator2 = new Zend_Paginator($adapter2); + $paginator2 + ->setCurrentPageNumber(1) + ->setItemCountPerPage(2); + $paginator2->getCurrentItems(); + } } class Zend_Paginator_TestArrayAggregate implements Zend_Paginator_AdapterAggregate Index: Zend/Paginator/_files/Zf6989.php =================================================================== --- Zend/Paginator/_files/Zf6989.php (revision 0) +++ Zend/Paginator/_files/Zf6989.php (revision 0) @@ -0,0 +1,55 @@ +_adapterSource = $adapterSource; + } + + public function count() + { + return $this->_adapterSource->count(); + } + + public function getItems($pageNumber, $itemCountPerPage) + { + $this->_adapterSource + ->setPageNumber($pageNumber) + ->setItemsPerPage($itemCountPerPage); + return $this->_adapterSource->execute(); + } +} Index: Zend/Paginator/_files/Zf6989_AdapterSource.php =================================================================== --- Zend/Paginator/_files/Zf6989_AdapterSource.php (revision 0) +++ Zend/Paginator/_files/Zf6989_AdapterSource.php (revision 0) @@ -0,0 +1,35 @@ +_data = range(0, $num); + } + + public function setPageNumber($page) { + $this->_page = $page; + return $this; + } + + public function count() { + return $this->_count; + } + + public function setItemsPerPage($itemsPerPage) { + $this->_itemsPerPage = $itemsPerPage; + return $this; + } + + public function execute() { + $this->_count = count($this->_data); + return $this->_data; + } + +}