/** * testOutOfRangePageNumberAndPageCountZero * * @return void */ public function testOutOfRangePageNumberAndPageCountZero() { $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost'); $Controller->params['named'] = array('page' => '3000'); $Controller->constructClasses(); $Controller->PaginatorControllerPost->recursive = 0; $Controller->paginate = array('conditions' => array('PaginatorControllerPost.id >' => 100)); try { $Controller->Paginator->paginate('PaginatorControllerPost'); $this->fail(); } catch (NotFoundException $e) { $this->assertEquals(1, $Controller->request->params['paging']['PaginatorControllerPost']['page'], 'Page number should not be 0'); } }
/** * testOutOfRangePageNumberAndPageCountZero * * @expectedException NotFoundException * @return void */ public function testOutOfRangePageNumberAndPageCountZero() { $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost'); $Controller->params['named'] = array('page' => '3000'); $Controller->constructClasses(); $Controller->PaginatorControllerPost->recursive = 0; $Controller->paginate = array('conditions' => array('PaginatorControllerPost.id >' => 100)); $Controller->Paginator->paginate('PaginatorControllerPost'); }
/** * Tests for missing models * * @expectedException MissingModelException */ function testPaginateMissingModel() { $request = new CakeRequest('controller_posts/index'); $request->params['pass'] = $request->params['named'] = array(); $Controller = new PaginatorTestController($request); $Controller->constructClasses(); $Controller->Paginator->paginate('MissingModel'); }
/** * Tests for missing models * * @expectedException MissingModelException */ public function testPaginateMissingModel() { $Controller = new PaginatorTestController($this->request); $Controller->constructClasses(); $Controller->Paginator->paginate('MissingModel'); }
/** * Test that a really large page number gets clamped to the max page size. */ public function testOutOfRangePageNumberGetsClamped() { $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost'); $Controller->params['named'] = array('page' => 3000); $Controller->constructClasses(); $Controller->PaginatorControllerPost->recursive = 0; $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEquals(1, $Controller->request->params['paging']['PaginatorControllerPost']['page'], 'Super big page number should be capped to max number of pages'); $Controller->paginate = array('conditions' => array('PaginatorControllerPost.id >' => 100)); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEquals(1, $Controller->request->params['paging']['PaginatorControllerPost']['page'], 'Page number should not be 0'); }