diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index 441b665a5f..ad949c7247 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -26,7 +26,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase /** * @expectedException \RuntimeException */ - public function testHandleWhenControllerThrowsAnExceptionAndRawIsTrue() + public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue() { $kernel = new HttpKernel(new EventDispatcher(), $this->getResolver(function () { throw new \RuntimeException(); })); @@ -36,14 +36,14 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase /** * @expectedException \RuntimeException */ - public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalseAndNoListenerIsRegistered() + public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered() { $kernel = new HttpKernel(new EventDispatcher(), $this->getResolver(function () { throw new \RuntimeException(); })); $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false); } - public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse() + public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrueWithAHandlingListener() { $dispatcher = new EventDispatcher(); $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { @@ -51,12 +51,26 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase }); $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new \RuntimeException('foo'); })); - $response = $kernel->handle(new Request()); + $response = $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); $this->assertEquals('500', $response->getStatusCode()); $this->assertEquals('foo', $response->getContent()); } + /** + * @expectedException \RuntimeException + */ + public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrueWithANonHandlingListener() + { + $dispatcher = new EventDispatcher(); + $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { + // should set a response, but does not + }); + + $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new \RuntimeException('foo'); })); + $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); + } + public function testHandleExceptionWithARedirectionResponse() { $dispatcher = new EventDispatcher();