mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Making unknown errors with codes higher than 500 render as error500.
Test added.
This commit is contained in:
parent
504b4d495f
commit
60ada4432a
2 changed files with 19 additions and 1 deletions
|
@ -107,7 +107,7 @@ class ExceptionRenderer {
|
|||
}
|
||||
} elseif (!$methodExists) {
|
||||
$method = 'error500';
|
||||
if ($code >= 400) {
|
||||
if ($code >= 400 && $code < 500) {
|
||||
$method = 'error400';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue