Browse Source

Fix deprecated request property use in paginator helper & tests.

Mark Story 8 years ago
parent
commit
51abd06479
2 changed files with 194 additions and 167 deletions
  1. 9 9
      src/View/Helper/PaginatorHelper.php
  2. 185 158
      tests/TestCase/View/Helper/PaginatorHelperTest.php

+ 9 - 9
src/View/Helper/PaginatorHelper.php

@@ -104,7 +104,7 @@ class PaginatorHelper extends Helper
         unset($query['page'], $query['limit'], $query['sort'], $query['direction']);
         $this->setConfig(
             'options.url',
-            array_merge($this->request->getParam('pass'), ['?' => $query])
+            array_merge($this->request->getParam('pass', []), ['?' => $query])
         );
     }
 
@@ -153,19 +153,19 @@ class PaginatorHelper extends Helper
     public function options(array $options = [])
     {
         if (!empty($options['paging'])) {
-            if (!$this->request->getParam('paging')) {
-                $this->request->params['paging'] = [];
-            }
-            $this->request->params['paging'] = $options['paging'] + $this->request->getParam('paging');
+            $this->request = $this->request->withParam(
+                'paging',
+                $options['paging'] + $this->request->getParam('paging', [])
+            );
             unset($options['paging']);
         }
         $model = $this->defaultModel();
 
         if (!empty($options[$model])) {
-            if (!$this->request->getParam('paging.' . $model)) {
-                $this->request->params['paging'][$model] = [];
-            }
-            $this->request->params['paging'][$model] = $options[$model] + $this->request->getParam('paging.' . $model);
+            $this->request = $this->request->withParam(
+                'paging.' . $model,
+                $options[$model] + (array)$this->request->getParam('paging.' . $model, [])
+            );
             unset($options[$model]);
         }
         $this->_config['options'] = array_filter($options + $this->_config['options']);

File diff suppressed because it is too large
+ 185 - 158
tests/TestCase/View/Helper/PaginatorHelperTest.php