/**
  * Tests the setCurrentPage() method.
  *
  * @see \Drupal\views\Plugin\views\pager\PagerPluginBase::setCurrentPage()
  */
 public function testSetCurrentPage()
 {
     $this->pager->setCurrentPage(2);
     $this->assertEquals(2, $this->pager->getCurrentPage());
     // A non numeric number or number below 0 should return 0.
     $this->pager->setCurrentPage('two');
     $this->assertEquals(0, $this->pager->getCurrentPage());
     $this->pager->setCurrentPage(-2);
     $this->assertEquals(0, $this->pager->getCurrentPage());
 }
Exemple #2
0
 /**
  * Get the current page from the pager.
  */
 public function getCurrentPage()
 {
     // If the pager is already initialized, pass it through to the pager.
     if (!empty($this->pager)) {
         return $this->pager->getCurrentPage();
     }
     if (isset($this->current_page)) {
         return $this->current_page;
     }
 }