@@ -486,4 +486,43 @@ function testPaginateMissingModel() {
486
486
$ Controller ->constructClasses ();
487
487
$ Controller ->Paginator ->paginate ('MissingModel ' );
488
488
}
489
+
490
+ /**
491
+ * testPaginateMaxLimit
492
+ *
493
+ * @return void
494
+ * @access public
495
+ */
496
+ function testPaginateMaxLimit () {
497
+ $ request = new CakeRequest ('controller_posts/index ' );
498
+ $ request ->params ['pass ' ] = $ request ->params ['named ' ] = array ();
499
+
500
+ $ Controller = new Controller ($ request );
501
+
502
+ $ Controller ->uses = array ('ControllerPost ' , 'ControllerComment ' );
503
+ $ Controller ->passedArgs [] = '1 ' ;
504
+ $ Controller ->params ['url ' ] = array ();
505
+ $ Controller ->constructClasses ();
506
+
507
+ $ Controller ->passedArgs = array ('contain ' => array ('ControllerComment ' ), 'limit ' => '1000 ' );
508
+ $ result = $ Controller ->paginate ('ControllerPost ' );
509
+ $ this ->assertEqual ($ Controller ->params ['paging ' ]['ControllerPost ' ]['options ' ]['limit ' ], 100 );
510
+
511
+ $ Controller ->passedArgs = array ('contain ' => array ('ControllerComment ' ), 'limit ' => '1000 ' , 'maxLimit ' => 1000 );
512
+ $ result = $ Controller ->paginate ('ControllerPost ' );
513
+ $ this ->assertEqual ($ Controller ->params ['paging ' ]['ControllerPost ' ]['options ' ]['limit ' ], 100 );
514
+
515
+ $ Controller ->passedArgs = array ('contain ' => array ('ControllerComment ' ), 'limit ' => '10 ' );
516
+ $ result = $ Controller ->paginate ('ControllerPost ' );
517
+ $ this ->assertEqual ($ Controller ->params ['paging ' ]['ControllerPost ' ]['options ' ]['limit ' ], 10 );
518
+
519
+ $ Controller ->passedArgs = array ('contain ' => array ('ControllerComment ' ), 'limit ' => '1000 ' );
520
+ $ Controller ->paginate = array ('maxLimit ' => 2000 );
521
+ $ result = $ Controller ->paginate ('ControllerPost ' );
522
+ $ this ->assertEqual ($ Controller ->params ['paging ' ]['ControllerPost ' ]['options ' ]['limit ' ], 1000 );
523
+
524
+ $ Controller ->passedArgs = array ('contain ' => array ('ControllerComment ' ), 'limit ' => '5000 ' );
525
+ $ result = $ Controller ->paginate ('ControllerPost ' );
526
+ $ this ->assertEqual ($ Controller ->params ['paging ' ]['ControllerPost ' ]['options ' ]['limit ' ], 2000 );
527
+ }
489
528
}
0 commit comments