From 0c99b4f0ab1106de16284aae91fcafed8150a5da Mon Sep 17 00:00:00 2001
From: Michael <mike@saymikeo.com>
Date: Fri, 11 May 2018 10:45:49 -0400
Subject: [PATCH 1/3] remove 5.4, upgrade to cakephp 3.6, upgrade phpunit to 5

---
 .travis.yml                                   |  3 --
 composer.json                                 |  8 +++---
 .../Component/ApiPaginationComponent.php      | 12 ++++----
 .../Component/ApiPaginationComponentTest.php  | 28 ++++++++++++-------
 4 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 3fff262..57e98a7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,6 @@ env:
     - RUN_TESTS=1
 
 php:
-  - 5.4
   - 5.5
   - 5.6
   - 7.0
@@ -16,8 +15,6 @@ sudo: false
 
 matrix:
   include:
-    - php: 5.4
-      env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
     - php: 5.6
       env: PHPCS=1 RUN_TESTS=0
 
diff --git a/composer.json b/composer.json
index 00b7322..a40ea6c 100644
--- a/composer.json
+++ b/composer.json
@@ -16,12 +16,12 @@
         }
     ],
     "require": {
-        "php": ">=5.4.16",
-        "cakephp/cakephp": "~3.0"
+        "php": ">=5.6",
+        "cakephp/cakephp": "~3.6"
     },
     "require-dev": {
-        "phpunit/phpunit" : "~4.0",
-        "scrutinizer/ocular": "~1.1",
+        "phpunit/phpunit" : "~5.0",
+        "scrutinizer/ocular": "1.1",
         "squizlabs/php_codesniffer": "~2.3.0"
     },
     "autoload": {
diff --git a/src/Controller/Component/ApiPaginationComponent.php b/src/Controller/Component/ApiPaginationComponent.php
index 136646c..b5944ea 100644
--- a/src/Controller/Component/ApiPaginationComponent.php
+++ b/src/Controller/Component/ApiPaginationComponent.php
@@ -42,9 +42,9 @@ public function beforeRender(Event $event)
             return;
         }
 
-        $subject = $event->subject();
-        $this->pagingInfo = $this->request->params['paging'][$subject->name];
-        $config = $this->config();
+        $subject = $event->getSubject();
+        $this->pagingInfo = $this->request->getParam('paging')[$subject->getName()];
+        $config = $this->getConfig();
 
         if (!empty($config['aliases'])) {
             $this->setAliases();
@@ -66,7 +66,7 @@ public function beforeRender(Event $event)
      */
     protected function setAliases()
     {
-        foreach ($this->config('aliases') as $key => $value) {
+        foreach ($this->getConfig('aliases') as $key => $value) {
             $this->pagingInfo[$value] = $this->pagingInfo[$key];
             unset($this->pagingInfo[$key]);
         }
@@ -80,7 +80,7 @@ protected function setAliases()
      */
     protected function setVisibility()
     {
-        $visible = $this->config('visible');
+        $visible = $this->getConfig('visible');
         foreach ($this->pagingInfo as $key => $value) {
             if (!in_array($key, $visible)) {
                 unset($this->pagingInfo[$key]);
@@ -96,7 +96,7 @@ protected function setVisibility()
      */
     protected function isPaginatedApiRequest()
     {
-        if (isset($this->request->params['paging']) &&
+        if ($this->request->getParam('paging') &&
             $this->request->is(['json', 'xml'])
         ) {
             return true;
diff --git a/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php b/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php
index 65c07db..be75d76 100644
--- a/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php
+++ b/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php
@@ -4,13 +4,15 @@
 use BryanCrowe\ApiPagination\Controller\Component\ApiPaginationComponent;
 use BryanCrowe\ApiPagination\TestApp\Controller\ArticlesController;
 use Cake\Event\Event;
-use Cake\Network\Request;
-use Cake\Network\Response;
+use Cake\Http\ServerRequest as Request;
+use Cake\Http\Response;
 use Cake\ORM\TableRegistry;
 use Cake\TestSuite\TestCase;
 
 /**
  * ApiPaginationComponentTest class
+ *
+ * @property ArticlesController $controller
  */
 class ApiPaginationComponentTest extends TestCase
 {
@@ -24,7 +26,7 @@ class ApiPaginationComponentTest extends TestCase
     public function setUp()
     {
         $this->request = new Request('/articles');
-        $this->response = $this->getMock('Cake\Network\Response');
+        $this->response = $this->createMock('Cake\Http\Response');
         $this->controller = new ArticlesController($this->request, $this->response);
         $this->Articles = TableRegistry::get('BryanCrowe/ApiPagination.Articles', ['table' => 'bryancrowe_articles']);
         parent::setUp();
@@ -61,7 +63,7 @@ public function testNonApiPaginatedRequest()
      */
     public function testDefaultPaginationSettings()
     {
-        $this->request->env('HTTP_ACCEPT', 'application/json');
+        $this->controller->request = $this->controller->request->withEnv('HTTP_ACCEPT', 'application/json');
         $this->controller->set('data', $this->controller->paginate($this->Articles));
         $apiPaginationComponent = new ApiPaginationComponent($this->controller->components());
         $event = new Event('Controller.beforeRender', $this->controller);
@@ -81,7 +83,9 @@ public function testDefaultPaginationSettings()
             'direction' => false,
             'limit' => null,
             'sortDefault' => false,
-            'directionDefault' => false
+            'directionDefault' => false,
+            'scope' => null,
+            'completeSort' => []
         ];
 
         $this->assertSame($expected, $result);
@@ -94,7 +98,7 @@ public function testDefaultPaginationSettings()
      */
     public function testVisibilitySettings()
     {
-        $this->request->env('HTTP_ACCEPT', 'application/json');
+        $this->controller->request = $this->controller->request->withEnv('HTTP_ACCEPT', 'application/json');
         $this->controller->set('data', $this->controller->paginate($this->Articles));
         $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [
             'visible' => [
@@ -129,7 +133,7 @@ public function testVisibilitySettings()
      */
     public function testAliasSettings()
     {
-        $this->request->env('HTTP_ACCEPT', 'application/json');
+        $this->controller->request = $this->controller->request->withEnv('HTTP_ACCEPT', 'application/json');
         $this->controller->set('data', $this->controller->paginate($this->Articles));
         $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [
             'aliases' => [
@@ -153,6 +157,8 @@ public function testAliasSettings()
             'limit' => null,
             'sortDefault' => false,
             'directionDefault' => false,
+            'scope' => null,
+            'completeSort' => [],
             'curPage' => 1,
             'currentCount' => 20,
             'totalCount' => 23,
@@ -168,7 +174,7 @@ public function testAliasSettings()
      */
     public function testKeySetting()
     {
-        $this->request->env('HTTP_ACCEPT', 'application/json');
+        $this->controller->request = $this->controller->request->withEnv('HTTP_ACCEPT', 'application/json');
         $this->controller->set('data', $this->controller->paginate($this->Articles));
         $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [
             'key' => 'paging'
@@ -190,7 +196,9 @@ public function testKeySetting()
             'direction' => false,
             'limit' => null,
             'sortDefault' => false,
-            'directionDefault' => false
+            'directionDefault' => false,
+            'scope' => null,
+            'completeSort' => []
         ];
 
         $this->assertSame($expected, $result);
@@ -203,7 +211,7 @@ public function testKeySetting()
      */
     public function testAllSettings()
     {
-        $this->request->env('HTTP_ACCEPT', 'application/json');
+        $this->controller->request = $this->controller->request->withEnv('HTTP_ACCEPT', 'application/json');
         $this->controller->set('data', $this->controller->paginate($this->Articles));
         $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [
             'key' => 'fun',

From 09643ad308ca26f39ab1e7adf12ce30a373b91e6 Mon Sep 17 00:00:00 2001
From: Michael <mike@saymikeo.com>
Date: Fri, 11 May 2018 10:50:25 -0400
Subject: [PATCH 2/3] remove 5.5 tests

---
 .travis.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 57e98a7..a7d438f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,6 @@ env:
     - RUN_TESTS=1
 
 php:
-  - 5.5
   - 5.6
   - 7.0
   - hhvm

From b0df9637dcc6a7a49ea9b400d09c55827be32db5 Mon Sep 17 00:00:00 2001
From: Michael <mike@saymikeo.com>
Date: Thu, 17 May 2018 14:30:25 -0400
Subject: [PATCH 3/3] update travis vars

---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index a7d438f..905a3eb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ before_script:
   - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
 
 script:
-  - sh -c "if [ '$RUN_TESTS' = '1' ]; then phpunit --coverage-text --coverage-clover=coverage.clover; fi"
+  - sh -c "if [ '$RUN_TESTS' = '1' ]; then vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover; fi"
   - sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p -n --extensions=php --standard=psr2 ./src ./tests; fi"
 
 after_script: