Commit 4d5ffca8 authored by Igor Wiedler's avatar Igor Wiedler

add test case for late listeners

parent 51df9f5a
......@@ -209,13 +209,36 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
try {
$request = Request::create('/foo');
$this->checkRouteResponse($app, '/foo', 'foo exception handler', 'should accept a string response from the error handler');
$app->handle($request);
$this->fail('->handle() should not catch exceptions thrown from an error handler');
} catch (\RuntimeException $e) {
$this->assertEquals('foo exception handler exception', $e->getMessage());
}
}
public function testRemoveExceptionHandlerAfterDispatcherAccess()
{
$app = new Application();
$app->match('/foo', function () {
throw new \RuntimeException('foo exception');
});
$app->before(function () {
// just making sure the dispatcher gets created
});
unset($app['exception_handler']);
try {
$request = Request::create('/foo');
$app->handle($request);
$this->fail('default exception handler should have been removed');
} catch (\RuntimeException $e) {
$this->assertEquals('foo exception', $e->getMessage());
}
}
protected function checkRouteResponse($app, $path, $expectedContent, $method = 'get', $message = null)
{
$request = Request::create($path, $method);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment