/**
  * @dataProvider getOffsets
  *
  * @param int $max_navigate
  * @param int $current_page
  * @param int $total_pages
  * @param int $left_offset
  * @param int $right_offset
  */
 public function testBuildOffset($max_navigate, $current_page, $total_pages, $left_offset, $right_offset)
 {
     $this->config->expects($this->exactly(2))->method('getMaxNavigate')->will($this->returnValue($max_navigate));
     $this->config->expects($this->atLeastOnce())->method('getCurrentPage')->will($this->returnValue($current_page));
     $this->config->expects($this->atLeastOnce())->method('getTotalPages')->will($this->returnValue($total_pages));
     $this->assertEquals($left_offset, $this->range->getLeftOffset());
     $this->assertEquals($right_offset, $this->range->getRightOffset());
 }
Exemplo n.º 2
0
 public function testGetIteratorEmpty()
 {
     $this->config->expects($this->once())->method('getTotalPages')->will($this->returnValue(1));
     $this->config->expects($this->never())->method('getCurrentPage');
     $this->config->expects($this->never())->method('getPageLink');
     $this->config->expects($this->never())->method('getFirstPageLink');
     $this->range->expects($this->never())->method('getLeftOffset');
     $this->range->expects($this->never())->method('getRightOffset');
     $this->assertEquals(new ArrayCollection(), $this->view->getIterator());
 }
Exemplo n.º 3
0
 /**
  * @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;
 }