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 renderPagination(array $payload, Paginator $paginator, FileItem $template) { if ($template) { $paginatorItemTemplate = new PageItem($template, $this->configuration); $paginatorItemTemplate->setPostConverterContent($paginatorItemTemplate->getPreConverterContent()); if ($paginator->pageChanged() && $paginatorItemTemplate) { $payload['page'] = $paginatorItemTemplate->getPayload(); $payload['paginator'] = $this->getPaginatorPayload($paginator); $event = $this->events->dispatchBeforeRenderPagination($this->renderizer, $payload, $paginatorItemTemplate); $this->renderizer->renderItem($paginatorItemTemplate, $event->getPayload()); $this->events->dispatchAfterRenderPagination($this->renderizer, $payload, $paginatorItemTemplate); $relativePath = $this->getPageRelativePath($paginator->getCurrentPage()); $paginatorItemTemplate->getFileItem()->setDestinationPaths([$relativePath]); $this->saveItem($paginatorItemTemplate); } } $paginator->nextItem(); }