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

Test added.
This commit is contained in:
mark_story 2010-12-11 13:30:29 -05:00
parent 504b4d495f
commit 60ada4432a
2 changed files with 19 additions and 1 deletions

View file

@ -107,7 +107,7 @@ class ExceptionRenderer {
}
} elseif (!$methodExists) {
$method = 'error500';
if ($code >= 400) {
if ($code >= 400 && $code < 500) {
$method = 'error400';
}
}

View file

@ -322,6 +322,24 @@ class ExceptionRendererTest extends CakeTestCase {
$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
*