haveToPaginate() public method

Return true if it's necessary to paginate or false if not.
public haveToPaginate ( ) : boolean
return boolean
Beispiel #1
0
 public function testPagerGetterMethodsShouldReturnExpectedValues()
 {
     // stub paginate
     $paginate = new stdClass();
     $paginate->total_pages = 20;
     $paginate->current = 10;
     $paginate->last = 20;
     $paginate->total_items = 100;
     $paginate->first = 1;
     $paginate->before = $paginate->current - 1;
     $paginate->next = $paginate->current + 1;
     $paginate->items = new \ArrayIterator([1, 2, 4, 5]);
     $mock = Mockery::mock(self::BUILDER_CLASS);
     $mock->shouldReceive('getPaginate')->once()->andReturn($paginate);
     $mock->shouldReceive('getLimit')->once()->andReturn(null);
     $pager = new Pager($mock, ['rangeLength' => 5, 'urlMask' => 'xxx']);
     $this->assertEquals($paginate->current, $pager->getCurrentPage());
     $this->assertEquals($paginate->total_items, $pager->count());
     $this->assertEquals(1, $pager->getFirstPage());
     $this->assertTrue($pager->haveToPaginate());
     $this->assertEquals($paginate->before, $pager->getPreviousPage());
     $this->assertEquals($paginate->next, $pager->getNextPage());
     $this->assertInstanceOf('Iterator', $pager->getIterator());
 }