public function testPaginatorZeroSize() { $paginator = new Paginator(['a', 'b', 'c', 'd'], 0); $this->assertEquals(0, $paginator->getTotalPages()); $this->assertEquals(0, $paginator->getTotalItems()); $this->assertEquals(0, $paginator->getItemsPerPage()); $this->assertEquals(1, $paginator->getCurrentPage()); $this->assertNull($paginator->getItemsCurrentPage()); $this->assertNull($paginator->getItem()); $this->assertTrue($paginator->pageChanged()); $this->assertFalse($paginator->nextItem()); }
private function getPaginatorPayload(Paginator $paginator) { $result = []; $result['per_page'] = $paginator->getItemsPerPage(); $result['posts'] = $paginator->getItemsCurrentPage(); $result['total_posts'] = $paginator->getTotalItems(); $result['total_pages'] = $paginator->getTotalPages(); $result['page'] = $paginator->getCurrentPage(); $result['previous_page'] = $paginator->getPreviousPage(); $result['previous_page_path'] = $this->getPageRelativePath($result['previous_page']); $result['next_page'] = $paginator->getNextPage(); $result['next_page_path'] = $this->getPageRelativePath($result['next_page']); return $result; }