Esempio n. 1
0
 public function testCacheDoesNotDisturbResultsWhenChangingParam()
 {
     $this->paginator->setCurrentPageNumber(1)->getCurrentItems();
     $pageItems = $this->paginator->setItemCountPerPage(5)->getCurrentItems();
     $expected = new \ArrayIterator(range(1, 5));
     $this->assertEquals($expected, $pageItems);
     $pageItems = $this->paginator->getItemsByPage(2);
     $expected = new \ArrayIterator(range(6, 10));
     $this->assertEquals($expected, $pageItems);
     // change the inside Paginator scale
     $pageItems = $this->paginator->setItemCountPerPage(8)->setCurrentPageNumber(3)->getCurrentItems();
     $pageItems = $this->paginator->getPageItemCache();
     $expected = new \ArrayIterator(range(17, 24));
     $this->assertEquals($expected, $pageItems[3]);
     // get back to already cached data
     $this->paginator->setItemCountPerPage(5);
     $pageItems = $this->paginator->getPageItemCache();
     $expected = array(1 => new \ArrayIterator(range(1, 5)), 2 => new \ArrayIterator(range(6, 10)));
     $this->assertEquals($expected[1], $pageItems[1]);
     $this->assertEquals($expected[2], $pageItems[2]);
 }