public function estIssue826()
 {
     $this->_loadDI();
     $personnes = Personnes::find();
     $paginator = new Phalcon\Paginator\Adapter\Model(array('data' => $personnes, 'limit' => 1, 'page' => 1));
     $paginator->setCurrentPage(2179);
     $page = $paginator->getPaginate();
     $this->assertEquals(count($page->items), 1);
     $this->assertEquals($page->before, 2178);
     $this->assertEquals($page->next, 2180);
     $this->assertEquals($page->last, 2180);
     $this->assertEquals($page->current, 2179);
     $this->assertEquals($page->total_pages, 2180);
 }
Exemple #2
0
 public function testModelPaginator()
 {
     require 'unit-tests/config.db.php';
     if (empty($configMysql)) {
         $this->markTestSkipped('Test skipped');
         return;
     }
     $this->_loadDI();
     $personnes = Personnes::find();
     $paginator = new Phalcon\Paginator\Adapter\Model(array('data' => $personnes, 'limit' => 10, 'page' => 1));
     //First Page
     $page = $paginator->getPaginate();
     $this->assertEquals(get_class($page), 'stdClass');
     $this->assertEquals(count($page->items), 10);
     $this->assertEquals($page->before, 1);
     $this->assertEquals($page->next, 2);
     $this->assertEquals($page->last, 218);
     $this->assertEquals($page->limit, 10);
     $this->assertEquals($page->current, 1);
     $this->assertEquals($page->total_pages, 218);
     //Middle Page
     $paginator->setCurrentPage(50);
     $page = $paginator->getPaginate();
     $this->assertEquals(get_class($page), 'stdClass');
     $this->assertEquals(count($page->items), 10);
     $this->assertEquals($page->before, 49);
     $this->assertEquals($page->next, 51);
     $this->assertEquals($page->last, 218);
     $this->assertEquals($page->current, 50);
     $this->assertEquals($page->total_pages, 218);
     //Last Page
     $paginator->setCurrentPage(218);
     $page = $paginator->getPaginate();
     $this->assertEquals(get_class($page), 'stdClass');
     $this->assertEquals(count($page->items), 10);
     $this->assertEquals($page->before, 217);
     $this->assertEquals((int) $page->next, 218);
     $this->assertEquals($page->last, 218);
     $this->assertEquals($page->current, 218);
     $this->assertEquals($page->total_pages, 218);
 }