|
|
@@ -805,6 +805,35 @@ class PaginatorComponentTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 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'
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* test that fields not in whitelist won't be part of order conditions.
|
|
|
*
|
|
|
* @return void
|