Esempio n. 1
0
 public function testGetView()
 {
     $view = $this->config->getView();
     $this->assertInstanceOf('\\AnimeDb\\Bundle\\AppBundle\\Util\\Pagination\\View', $view);
     // test lazy load
     $this->config->setPageLink('?p=%s');
     $this->assertEquals($view, $this->config->getView());
 }
Esempio n. 2
0
 /**
  * @dataProvider getNodes
  *
  * @param int $total_pages
  * @param int $current_page
  * @param int $max_navigate
  * @param string|\Closure $page_link
  * @param string $first_page_link
  * @param ArrayCollection $list
  */
 public function testGetIterator($total_pages, $current_page, $max_navigate, $page_link, $first_page_link, $list)
 {
     $this->config->expects($this->any())->method('getTotalPages')->will($this->returnValue($total_pages));
     $this->config->expects($this->any())->method('getCurrentPage')->will($this->returnValue($current_page));
     $this->config->expects($this->any())->method('getMaxNavigate')->will($this->returnValue($max_navigate));
     $this->config->expects($this->any())->method('getPageLink')->will($this->returnValue($page_link));
     $this->config->expects($this->any())->method('getFirstPageLink')->will($this->returnValue($first_page_link));
     $this->assertEquals($list, $this->view->getIterator());
 }
Esempio n. 3
0
 /**
  * @param int $page
  *
  * @return string
  */
 protected function buildLink($page)
 {
     if ($page == 1 && $this->config->getFirstPageLink()) {
         return $this->config->getFirstPageLink();
     }
     if (is_callable($this->config->getPageLink())) {
         return call_user_func($this->config->getPageLink(), $page);
     } else {
         return sprintf($this->config->getPageLink(), $page);
     }
 }