$results->setPage(2); $t->diag('testing ->getResults()'); $t->is_deeply($results->getResults()->toArray(), range(10, 20), '->getResults() returns the correct range'); $results->setPage(3); $t->is_deeply($results->getResults()->toArray(), range(20, 30), '->getResults() returns the correct range after page change'); $results->setMaxPerPage(0); $t->is_deeply($results->getResults()->toArray(), range(0, 1000), '->getResults() returns all results if the max per page is 0'); $results->setMaxPerPage(10); $t->diag('testing page numbers'); $t->is($results->getFirstPage(), 1, '->getFirstPage() returns 1 as first page'); $t->is($results->getLastPage(), 101, '->getLastPage() returns the last page in the range'); $t->is($results->getNextPage(), 4, '->getNextPage() returns the next page'); $results->setPage(101); $t->is($results->getNextPage(), 101, '->getNextPage() returns last page if at end'); $results->setPage(4); $t->is($results->getPreviousPage(), 3, '->getPreviousPage() returns the previous page'); $results->setPage(1); $t->is($results->getPreviousPage(), 1, '->getPreviousPage() returns the first page if at start'); $results->setPage(4); $t->diag('testing page indices'); $results->setPage(4); $t->is($results->getFirstIndice(), 31, '->getFirstIndice() returns correct first indice in results'); $t->is($results->getLastIndice(), 40, '->getLastIndice() returns correct last indice in result'); $results->setMaxPerPage(8); $results->setPage($results->getLastPage()); $t->is($results->getLastIndice(), 1001, '->getLastIndice() returns correct last indice if more can fit on the page'); $t->diag('testing link generator'); $results->setMaxPerPage(10); $results->setPage(4); $t->is($results->getLinks(5), range(2, 6), '->getLinks() returns the correct link range'); $results->setPage(1);