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:
parent
55142186de
commit
b9f180e001
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue