|
|
@@ -30,6 +30,8 @@ use Cake\Error;
|
|
|
use Cake\Error\ExceptionRenderer;
|
|
|
use Cake\Event\Event;
|
|
|
use Cake\Network\Error\SocketException;
|
|
|
+use Cake\Network\Exception\InternalErrorException;
|
|
|
+use Cake\Network\Exception\NotFoundException;
|
|
|
use Cake\Network\Request;
|
|
|
use Cake\ORM\Error\MissingBehaviorException;
|
|
|
use Cake\Routing\Router;
|
|
|
@@ -125,7 +127,7 @@ class MyCustomExceptionRenderer extends ExceptionRenderer {
|
|
|
* Exception class for testing app error handlers and custom errors.
|
|
|
*
|
|
|
*/
|
|
|
-class MissingWidgetThingException extends Error\NotFoundException {
|
|
|
+class MissingWidgetThingException extends NotFoundException {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -238,7 +240,7 @@ class ExceptionRendererTest extends TestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testConstruction() {
|
|
|
- $exception = new Error\NotFoundException('Page not found');
|
|
|
+ $exception = new NotFoundException('Page not found');
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
$this->assertInstanceOf('Cake\Controller\ErrorController', $ExceptionRenderer->controller);
|
|
|
@@ -362,7 +364,7 @@ class ExceptionRendererTest extends TestCase {
|
|
|
$request = new Request('posts/view/1000');
|
|
|
Router::setRequestInfo($request);
|
|
|
|
|
|
- $exception = new Error\NotFoundException('Custom message');
|
|
|
+ $exception = new NotFoundException('Custom message');
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
$ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', array('statusCode', '_sendHeader'));
|
|
|
$ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(404);
|
|
|
@@ -381,7 +383,7 @@ class ExceptionRendererTest extends TestCase {
|
|
|
public function testerror400OnlyChangingCakeException() {
|
|
|
Configure::write('debug', false);
|
|
|
|
|
|
- $exception = new Error\NotFoundException('Custom message');
|
|
|
+ $exception = new NotFoundException('Custom message');
|
|
|
$ExceptionRenderer = $this->_mockResponse(new ExceptionRenderer($exception));
|
|
|
|
|
|
$result = $ExceptionRenderer->render();
|
|
|
@@ -405,7 +407,7 @@ class ExceptionRendererTest extends TestCase {
|
|
|
$request = new Request('pages/<span id=333>pink</span></id><script>document.body.style.background = t=document.getElementById(333).innerHTML;window.alert(t);</script>');
|
|
|
Router::setRequestInfo($request);
|
|
|
|
|
|
- $exception = new Error\NotFoundException('Custom message');
|
|
|
+ $exception = new NotFoundException('Custom message');
|
|
|
$ExceptionRenderer = $this->_mockResponse(new ExceptionRenderer($exception));
|
|
|
|
|
|
$result = $ExceptionRenderer->render()->body();
|
|
|
@@ -420,7 +422,7 @@ class ExceptionRendererTest extends TestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testError500Message() {
|
|
|
- $exception = new Error\InternalErrorException('An Internal Error Has Occurred');
|
|
|
+ $exception = new InternalErrorException('An Internal Error Has Occurred');
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
$ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', array('statusCode', '_sendHeader'));
|
|
|
$ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(500);
|
|
|
@@ -435,7 +437,7 @@ class ExceptionRendererTest extends TestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testExceptionResponseHeader() {
|
|
|
- $exception = new Error\MethodNotAllowedException('Only allowing POST and DELETE');
|
|
|
+ $exception = new MethodNotAllowedException('Only allowing POST and DELETE');
|
|
|
$exception->responseHeader(array('Allow: POST, DELETE'));
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
@@ -628,7 +630,7 @@ class ExceptionRendererTest extends TestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testRenderExceptionInBeforeRender() {
|
|
|
- $exception = new Error\NotFoundException('Not there, sorry');
|
|
|
+ $exception = new NotFoundException('Not there, sorry');
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
$ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', array('beforeRender'));
|
|
|
@@ -652,7 +654,7 @@ class ExceptionRendererTest extends TestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testMissingSubdirRenderSafe() {
|
|
|
- $exception = new Error\NotFoundException();
|
|
|
+ $exception = new NotFoundException();
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
$ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', array('render'));
|
|
|
@@ -688,7 +690,7 @@ class ExceptionRendererTest extends TestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testMissingPluginRenderSafe() {
|
|
|
- $exception = new Error\NotFoundException();
|
|
|
+ $exception = new NotFoundException();
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
$ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', array('render'));
|
|
|
@@ -720,7 +722,7 @@ class ExceptionRendererTest extends TestCase {
|
|
|
*/
|
|
|
public function testMissingPluginRenderSafeWithPlugin() {
|
|
|
Plugin::load('TestPlugin');
|
|
|
- $exception = new Error\NotFoundException();
|
|
|
+ $exception = new NotFoundException();
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
$ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', array('render'));
|