Use 403 instead of 200 response

A forbidden should throw a 403 and this makes it easier for me to do some automated testing.
This commit is contained in:
Lukas Reschke 2015-01-29 12:04:54 +01:00
parent 55142186de
commit b9f180e001
2 changed files with 5 additions and 5 deletions

View File

@ -59,7 +59,9 @@ class SubadminMiddleware extends Middleware {
* @return TemplateResponse * @return TemplateResponse
*/ */
public function afterException($controller, $methodName, \Exception $exception) { public function afterException($controller, $methodName, \Exception $exception) {
return new TemplateResponse('core', '403', array(), 'guest'); $response = new TemplateResponse('core', '403', array(), 'guest');
$response->setStatus(Http::STATUS_FORBIDDEN);
return $response;
} }
} }

View File

@ -81,11 +81,9 @@ class SubadminMiddlewareTest extends \Test\TestCase {
$this->subadminMiddlewareAsSubAdmin->beforeController($this->controller, 'foo'); $this->subadminMiddlewareAsSubAdmin->beforeController($this->controller, 'foo');
} }
public function testAfterException() { public function testAfterException() {
$expectedResponse = new TemplateResponse('core', '403', array(), 'guest'); $expectedResponse = new TemplateResponse('core', '403', array(), 'guest');
$expectedResponse->setStatus(403);
$this->assertEquals($expectedResponse, $this->subadminMiddleware->afterException($this->controller, 'foo', new \Exception())); $this->assertEquals($expectedResponse, $this->subadminMiddleware->afterException($this->controller, 'foo', new \Exception()));
} }
} }