From a8e4c43080d71841531db63c4b35b81a8924dadf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 11 Apr 2015 08:34:27 +0200 Subject: [PATCH] renamed some confusing tests --- .../HttpKernel/Tests/HttpKernelTest.php | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) 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();