/** * @return ArrayCollection */ public function getIterator() { if (!$this->list instanceof ArrayCollection) { $this->list = new ArrayCollection(); if ($this->getTotal() > 1) { // determining the first and last pages in paging based on the current page and offset $page = $this->config->getCurrentPage() - $this->range->getLeftOffset(); $page_to = $this->config->getCurrentPage() + $this->range->getRightOffset(); while ($page <= $page_to) { $this->list->add(new Node($page, $this->buildLink($page), $page == $this->config->getCurrentPage())); ++$page; } } } return $this->list; }
/** * @dataProvider getConfigs * * @param int $total_pages * @param int $current_page */ public function testConstruct($total_pages, $current_page) { $config = new Configuration($total_pages, $current_page); $this->assertEquals($total_pages, $config->getTotalPages()); $this->assertEquals($current_page, $config->getCurrentPage()); }