Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
phpcbf src/ tests/
$ ./vendor/bin/phpcbf src/ tests/

PHPCBF RESULT SUMMARY
-----------------------------------------------------------------------------------------------------------------------------------
FILE                                                                                          FIXED  REMAINING
-----------------------------------------------------------------------------------------------------------------------------------
cakephp-api-pagination/src/Controller/Component/ApiPaginationComponent.php                    2      9
cakephp-api-pagination/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php     8      21
cakephp-api-pagination/tests/bootstrap.php                                                    1      2
-----------------------------------------------------------------------------------------------------------------------------------
A TOTAL OF 11 ERRORS WERE FIXED IN 3 FILES
-----------------------------------------------------------------------------------------------------------------------------------

Time: 372ms; Memory: 10MB
  • Loading branch information
mtak3 committed Feb 14, 2020
commit 88f2991825511fe8b0abcec30558cc4fd6e5e7bc
6 changes: 3 additions & 3 deletions src/Controller/Component/ApiPaginationComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ApiPaginationComponent extends Component
* Injects the pagination info into the response if the current request is a
* JSON or XML request with pagination.
*
* @param \Cake\Event\Event $event The Controller.beforeRender event.
* @param \Cake\Event\Event $event The Controller.beforeRender event.
* @return void
*/
public function beforeRender(Event $event)
Expand Down Expand Up @@ -98,8 +98,8 @@ protected function setVisibility()
*/
protected function isPaginatedApiRequest()
{
if ($this->getController()->getRequest()->getAttribute('paging') &&
$this->getController()->getRequest()->is(['json', 'xml'])
if ($this->getController()->getRequest()->getAttribute('paging')
&& $this->getController()->getRequest()->is(['json', 'xml'])
) {
return true;
}
Expand Down
24 changes: 16 additions & 8 deletions tests/TestCase/Controller/Component/ApiPaginationComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public function testVisibilitySettings()
$this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json')
);
$this->controller->set('data', $this->controller->paginate($this->Articles));
$apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [
$apiPaginationComponent = new ApiPaginationComponent(
$this->controller->components(), [
'visible' => [
'page',
'current',
Expand All @@ -116,7 +117,8 @@ public function testVisibilitySettings()
'nextPage',
'pageCount'
]
]);
]
);
$event = new Event('Controller.beforeRender', $this->controller);
$apiPaginationComponent->beforeRender($event);

Expand Down Expand Up @@ -144,13 +146,15 @@ public function testAliasSettings()
$this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json')
);
$this->controller->set('data', $this->controller->paginate($this->Articles));
$apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [
$apiPaginationComponent = new ApiPaginationComponent(
$this->controller->components(), [
'aliases' => [
'page' => 'curPage',
'current' => 'currentCount',
'count' => 'totalCount',
]
]);
]
);
$event = new Event('Controller.beforeRender', $this->controller);
$apiPaginationComponent->beforeRender($event);

Expand Down Expand Up @@ -190,9 +194,11 @@ public function testKeySetting()
$this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json')
);
$this->controller->set('data', $this->controller->paginate($this->Articles));
$apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [
$apiPaginationComponent = new ApiPaginationComponent(
$this->controller->components(), [
'key' => 'paging'
]);
]
);
$event = new Event('Controller.beforeRender', $this->controller);
$apiPaginationComponent->beforeRender($event);

Expand Down Expand Up @@ -232,7 +238,8 @@ public function testAllSettings()
$this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json')
);
$this->controller->set('data', $this->controller->paginate($this->Articles));
$apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [
$apiPaginationComponent = new ApiPaginationComponent(
$this->controller->components(), [
'key' => 'fun',
'aliases' => [
'page' => 'currentPage',
Expand All @@ -246,7 +253,8 @@ public function testAllSettings()
'prevPage',
'nextPage'
]
]);
]
);
$event = new Event('Controller.beforeRender', $this->controller);
$apiPaginationComponent->beforeRender($event);

Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
unset($findRoot);
chdir($root);
if (file_exists($root . '/config/bootstrap.php')) {
require $root . '/config/bootstrap.php';
include $root . '/config/bootstrap.php';
return;
}
require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';