Skip to content
Permalink
Browse files

Making unknown errors with codes higher than 500 render as error500.

Test added.
  • Loading branch information...
markstory committed Dec 11, 2010
1 parent 504b4d4 commit 60ada4432a1a52839f2f6a4cafdb0d6594a410e0
Showing with 19 additions and 1 deletion.
  1. +1 −1 cake/libs/error/exception_renderer.php
  2. +18 −0 cake/tests/cases/libs/error/exception_renderer.test.php
@@ -107,7 +107,7 @@ function __construct(Exception $exception) {
}
} elseif (!$methodExists) {
$method = 'error500';
if ($code >= 400) {
if ($code >= 400 && $code < 500) {
$method = 'error400';
}
}
@@ -322,6 +322,24 @@ function testUnknownExceptionTypeWithNoCodeIsA500() {
$this->assertEquals('error500', $ExceptionRenderer->method, 'incorrect method coercion.');
}
/**
* test that unknown exception types with valid status codes are treated correctly.
*
* @return void
*/
function testUnknownExceptionTypeWithCodeHigherThan500() {
$exception = new OutOfBoundsException('foul ball.', 501);
$ExceptionRenderer = new ExceptionRenderer($exception);
$ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader'));
$ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(501);
ob_start();
$ExceptionRenderer->render();
$results = ob_get_clean();
$this->assertEquals('error500', $ExceptionRenderer->method, 'incorrect method coercion.');
}
/**
* testerror400 method
*

0 comments on commit 60ada44

Please sign in to comment.
You can’t perform that action at this time.