Skip to content

Commit

Permalink
Merge pull request #592 from FriendsOfCake/issue-591
Browse files Browse the repository at this point in the history
Update namespace for deprecated exception classes.
  • Loading branch information
ADmad authored May 19, 2018
2 parents a516934 + b3b6880 commit fb272d3
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 30 deletions.
3 changes: 2 additions & 1 deletion src/Action/AddAction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Crud\Action;

use Crud\Error\Exception\ValidationException;
use Crud\Event\Subject;
use Crud\Traits\RedirectTrait;
use Crud\Traits\SaveMethodTrait;
Expand Down Expand Up @@ -61,7 +62,7 @@ class AddAction extends BaseAction
'error' => [
'exception' => [
'type' => 'validate',
'class' => '\Crud\Error\Exception\ValidationException'
'class' => ValidationException::class
]
]
],
Expand Down
2 changes: 1 addition & 1 deletion src/Action/BaseAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class BaseAction extends BaseObject
*
* @param array $args Arguments
* @return mixed
* @throws \Cake\Network\Exception\NotImplementedException if the action can't handle the request
* @throws \Cake\Http\Exception\NotImplementedException if the action can't handle the request
*/
public function handle($args = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/Action/Bulk/BaseAction.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Crud\Action\Bulk;

use Cake\Network\Exception\BadRequestException;
use Cake\Http\Exception\BadRequestException;
use Cake\ORM\Query;
use Cake\Utility\Hash;
use Crud\Action\BaseAction as CrudBaseAction;
Expand Down
5 changes: 3 additions & 2 deletions src/Action/EditAction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Crud\Action;

use Crud\Error\Exception\ValidationException;
use Crud\Event\Subject;
use Crud\Traits\FindMethodTrait;
use Crud\Traits\RedirectTrait;
Expand Down Expand Up @@ -78,7 +79,7 @@ class EditAction extends BaseAction
'error' => [
'exception' => [
'type' => 'validate',
'class' => '\Crud\Error\Exception\ValidationException'
'class' => ValidationException::class
]
]
],
Expand All @@ -90,7 +91,7 @@ class EditAction extends BaseAction
*
* @param string|null $id Record id
* @return void
* @throws \Cake\Network\Exception\NotFoundException If record not found
* @throws \Cake\Http\Exception\NotFoundException If record not found
*/
protected function _get($id = null)
{
Expand Down
11 changes: 7 additions & 4 deletions src/Controller/Component/CrudComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Cake\Controller\ComponentRegistry;
use Cake\Core\App;
use Cake\Event\Event;
use Cake\Http\Exception\BadRequestException;
use Cake\Http\Exception\MethodNotAllowedException;
use Cake\Http\Exception\NotFoundException;
use Cake\Http\Response;
use Cake\Utility\Inflector;
use Crud\Error\Exception\ActionNotConfiguredException;
Expand Down Expand Up @@ -108,17 +111,17 @@ class CrudComponent extends Component
'domain' => 'crud',
'invalidId' => [
'code' => 400,
'class' => 'Cake\Network\Exception\BadRequestException',
'class' => BadRequestException::class,
'text' => 'Invalid id'
],
'recordNotFound' => [
'code' => 404,
'class' => 'Cake\Network\Exception\NotFoundException',
'class' => NotFoundException::class,
'text' => 'Not found'
],
'badRequestMethod' => [
'code' => 405,
'class' => 'Cake\Network\Exception\MethodNotAllowedException',
'class' => MethodNotAllowedException::class,
'text' => 'Method not allowed. This action permits only {methods}'
]
],
Expand Down Expand Up @@ -221,7 +224,7 @@ public function startup(Event $event)
*
* @param string $controllerAction Override the controller action to execute as.
* @param array $args List of arguments to pass to the CRUD action (Usually an ID to edit / delete).
* @return \Cake\Network\Response
* @return \Cake\Http\Response
* @throws Exception If an action is not mapped.
*/
public function execute($controllerAction = null, $args = [])
Expand Down
2 changes: 1 addition & 1 deletion src/Core/ProxyTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function _listener($name)
*
* Primarily here to ease unit testing
*
* @return \Cake\Network\Session
* @return \Cake\Http\Session
* @codeCoverageIgnore
*/
protected function _session()
Expand Down
8 changes: 5 additions & 3 deletions src/Listener/ApiListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
use Cake\Core\Configure;
use Cake\Error\ErrorHandler;
use Cake\Event\Event;
use Cake\Http\Exception\BadRequestException;
use Cake\Http\Exception\MethodNotAllowedException;
use Cake\Http\ServerRequest;
use Cake\Utility\Hash;
use Cake\Utility\Text;
use Crud\Error\ExceptionRenderer;
use Crud\Event\Subject;

/**
Expand Down Expand Up @@ -38,11 +40,11 @@ class ApiListener extends BaseListener
],
'exception' => [
'type' => 'default',
'class' => 'Cake\Http\Exception\BadRequestException',
'class' => BadRequestException::class,
'message' => 'Unknown error',
'code' => 0
],
'exceptionRenderer' => 'Crud\Error\ExceptionRenderer',
'exceptionRenderer' => ExceptionRenderer::class,
'setFlash' => false
];

Expand Down Expand Up @@ -136,7 +138,7 @@ public function respond(Event $event)
/**
* Check for allowed HTTP request types
*
* @throws \Cake\Network\Exception\MethodNotAllowedException
* @throws \Cake\Http\Exception\MethodNotAllowedException
* @return bool
*/
protected function _checkRequestMethods()
Expand Down
9 changes: 6 additions & 3 deletions tests/TestCase/Action/BaseActionTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
namespace Crud\TestCase\Action;

use Cake\Http\Exception\BadRequestException;
use Cake\Http\Exception\MethodNotAllowedException;
use Cake\Http\Exception\NotFoundException;
use Cake\Http\ServerRequest;
use Cake\ORM\TableRegistry;
use Crud\Event\Subject;
Expand Down Expand Up @@ -441,7 +444,7 @@ public function testInvalidIdMessage()
{
$expected = [
'code' => 400,
'class' => 'Cake\Network\Exception\BadRequestException',
'class' => BadRequestException::class,
'element' => 'default',
'params' => [
'class' => 'message invalidId',
Expand All @@ -465,7 +468,7 @@ public function testRecordNotFoundMessage()
{
$expected = [
'code' => 404,
'class' => 'Cake\Network\Exception\NotFoundException',
'class' => NotFoundException::class,
'element' => 'default',
'params' => [
'class' => 'message recordNotFound',
Expand All @@ -489,7 +492,7 @@ public function testBadRequestMethodMessage()
{
$expected = [
'code' => 405,
'class' => 'Cake\Network\Exception\MethodNotAllowedException',
'class' => MethodNotAllowedException::class,
'element' => 'default',
'params' => [
'class' => 'message badRequestMethod',
Expand Down
29 changes: 15 additions & 14 deletions tests/TestCase/Controller/Component/CrudComponentTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
namespace Crud\TestCase\Controller\Crud;

use Cake\Controller\ComponentRegistry;
use Cake\Controller\Controller;
use Cake\Event\Event;
use Cake\Event\EventManager;
use Cake\Http\Exception\BadRequestException;
use Cake\Http\Exception\MethodNotAllowedException;
use Cake\Http\Exception\NotFoundException;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\ORM\TableRegistry;
Expand Down Expand Up @@ -593,17 +594,17 @@ public function testDefaultConfig()
'domain' => 'crud',
'invalidId' => [
'code' => 400,
'class' => 'Cake\Network\Exception\BadRequestException',
'class' => BadRequestException::class,
'text' => 'Invalid id'
],
'recordNotFound' => [
'code' => 404,
'class' => 'Cake\Network\Exception\NotFoundException',
'class' => NotFoundException::class,
'text' => 'Not found'
],
'badRequestMethod' => [
'code' => 405,
'class' => 'Cake\Network\Exception\MethodNotAllowedException',
'class' => MethodNotAllowedException::class,
'text' => 'Method not allowed. This action permits only {methods}'
]
],
Expand Down Expand Up @@ -639,17 +640,17 @@ public function testConstructMerging()
'domain' => 'crud',
'invalidId' => [
'code' => 400,
'class' => 'Cake\Network\Exception\BadRequestException',
'class' => BadRequestException::class,
'text' => 'Invalid id'
],
'recordNotFound' => [
'code' => 404,
'class' => 'Cake\Network\Exception\NotFoundException',
'class' => NotFoundException::class,
'text' => 'Not found'
],
'badRequestMethod' => [
'code' => 405,
'class' => 'Cake\Network\Exception\MethodNotAllowedException',
'class' => MethodNotAllowedException::class,
'text' => 'Method not allowed. This action permits only {methods}'
]
],
Expand Down Expand Up @@ -682,17 +683,17 @@ public function testConstructMerging2()
'domain' => 'crud',
'invalidId' => [
'code' => 400,
'class' => 'Cake\Network\Exception\BadRequestException',
'class' => BadRequestException::class,
'text' => 'Invalid id'
],
'recordNotFound' => [
'code' => 404,
'class' => 'Cake\Network\Exception\NotFoundException',
'class' => NotFoundException::class,
'text' => 'Not found'
],
'badRequestMethod' => [
'code' => 405,
'class' => 'Cake\Network\Exception\MethodNotAllowedException',
'class' => MethodNotAllowedException::class,
'text' => 'Method not allowed. This action permits only {methods}'
]
],
Expand Down Expand Up @@ -951,7 +952,7 @@ public function testConfigMergeWorks()

$expected = [
'code' => 500,
'class' => 'Cake\Network\Exception\BadRequestException',
'class' => BadRequestException::class,
'text' => 'Invalid id'
];
$result = $this->Crud->getConfig('messages.invalidId');
Expand All @@ -974,12 +975,12 @@ public function testConfigOverwrite()
],
'recordNotFound' => [
'code' => 404,
'class' => 'Cake\Network\Exception\NotFoundException',
'class' => NotFoundException::class,
'text' => 'Not found'
],
'badRequestMethod' => [
'code' => 405,
'class' => 'Cake\Network\Exception\MethodNotAllowedException',
'class' => MethodNotAllowedException::class,
'text' => 'Method not allowed. This action permits only {methods}'
]
];
Expand Down

0 comments on commit fb272d3

Please sign in to comment.