Example #1
0
 public function testGetPagerHtml()
 {
     $limit = 10;
     $this->layout->expects($this->once())->method('getChildName')->will($this->returnValue('product_list_toolbar_pager'));
     $this->layout->expects($this->once())->method('getBlock')->will($this->returnValue($this->pagerBlock));
     $this->productListHelper->expects($this->exactly(2))->method('getAvailableLimit')->will($this->returnValue([10 => 10, 20 => 20]));
     $this->model->expects($this->once())->method('getLimit')->will($this->returnValue($limit));
     $this->pagerBlock->expects($this->once())->method('setUseContainer')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setShowPerPage')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setShowAmounts')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setFrameLength')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setJump')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setLimit')->with($limit)->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('setCollection')->will($this->returnValue($this->pagerBlock));
     $this->pagerBlock->expects($this->once())->method('toHtml')->will($this->returnValue(true));
     $this->assertTrue($this->block->getPagerHtml());
 }
Example #2
0
 /**
  * Get filter item url
  *
  * @return string
  */
 public function getUrl()
 {
     $query = [$this->getFilter()->getRequestVar() => $this->getValue(), $this->_htmlPagerBlock->getPageVarName() => null];
     return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);
 }
 protected function _initFrame()
 {
     if (!$this->helper->isActiveEngine()) {
         return parent::_initFrame();
     }
     if (!$this->isFrameInitialized()) {
         $start = 0;
         $end = 0;
         $lastPageNum = $this->getLastPageNum();
         $currentPage = $this->getCurrentPage();
         if ($lastPageNum <= $this->getFrameLength()) {
             $start = 1;
             $end = $lastPageNum;
         } else {
             $half = ceil($this->getFrameLength() / 2);
             if ($currentPage >= $half && $currentPage <= $lastPageNum - $half) {
                 $start = $currentPage - $half + 1;
                 $end = $start + $this->getFrameLength() - 1;
             } elseif ($currentPage < $half) {
                 $start = 1;
                 $end = $this->getFrameLength();
             } elseif ($currentPage > $lastPageNum - $half) {
                 $end = $lastPageNum;
                 $start = $end - $this->getFrameLength() + 1;
             }
         }
         $this->_frameStart = $start;
         $this->_frameEnd = $end;
         $this->_setFrameInitialized(true);
     }
     return $this;
 }