/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); $this->_scrollingStyle = new \Zend\Paginator\ScrollingStyle\All(); $this->_paginator = \Zend\Paginator\Paginator::factory(range(1, 101)); $this->_paginator->setItemCountPerPage(10); }
/** * @group ZF-4151 */ public function testDoesNotThrowOutOfBoundsExceptionIfIteratorIsEmpty() { $this->_paginator = \Zend\Paginator\Paginator::factory(new \ArrayIterator(array())); $items = $this->_paginator->getCurrentItems(); foreach ($items as $item) { } }
/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); $this->_scrollingStyle = new \Zend\Paginator\ScrollingStyle\Jumping(); $this->_paginator = \Zend\Paginator\Paginator::factory(range(1, 101)); $this->_paginator->setItemCountPerPage(10); $this->_paginator->setPageRange(10); $this->_expectedRange = array_combine(range(1, 10), range(1, 10)); }
/** * @group ZF-3873 */ public function testAdapterReturnsCorrectValues() { $paginator = Paginator\Paginator::factory(2); $paginator->setCurrentPageNumber(1); $paginator->setItemCountPerPage(5); $pages = $paginator->getPages(); $this->assertEquals(2, $pages->currentItemCount); $this->assertEquals(2, $pages->lastItemNumber); $paginator = Paginator\Paginator::factory(19); $paginator->setCurrentPageNumber(4); $paginator->setItemCountPerPage(5); $pages = $paginator->getPages(); $this->assertEquals(4, $pages->currentItemCount); $this->assertEquals(19, $pages->lastItemNumber); }
/** * @group ZF-4328 */ public function testUsesPaginatorFromViewOnlyIfNoneSupplied() { $this->_viewHelper->getView()->vars()->paginator = $this->_paginator; $paginator = Paginator\Paginator::factory(range(1, 30)); Helper\PaginationControl::setDefaultViewPartial('testPagination.phtml'); $output = $this->_viewHelper->__invoke($paginator); $this->assertContains('page count (3)', $output, $output); }
/** * @group ZF-9396 */ public function testArrayAccessInClassSerializableLimitIterator() { $iterator = new \ArrayIterator(array('zf9396', 'foo', null)); $paginator = Paginator\Paginator::factory($iterator); $this->assertEquals('zf9396', $paginator->getItem(1)); $items = $paginator->getAdapter()->getItems(0, 10); $this->assertEquals('foo', $items[1]); $this->assertEquals(0, $items->key()); $this->assertFalse(isset($items[2])); $this->assertTrue(isset($items[1])); $this->assertFalse(isset($items[3])); }
/** * @group ZF-4151 */ public function testDoesNotThrowOutOfBoundsExceptionIfIteratorIsEmpty() { $this->_paginator = \Zend\Paginator\Paginator::factory(new \ArrayIterator(array())); $items = $this->_paginator->getCurrentItems(); try { foreach ($items as $item) { } } catch (\OutOfBoundsException $e) { $this->fail('Empty iterator caused in an OutOfBoundsException'); } }
/** * @group ZF-7602 */ public function testAcceptAndHandlePaginatorAdapterAggregateDataInFactory() { $p = Paginator\Paginator::factory(new TestArrayAggregate()); $this->assertEquals(1, count($p)); $this->assertType('Zend\\Paginator\\Adapter\\ArrayAdapter', $p->getAdapter()); $this->assertEquals(4, count($p->getAdapter())); }