@@ -26,7 +26,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
26
26
/**
27
27
* @expectedException \RuntimeException
28
28
*/
29
- public function testHandleWhenControllerThrowsAnExceptionAndRawIsTrue ()
29
+ public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue ()
30
30
{
31
31
$ kernel = new HttpKernel (new EventDispatcher (), $ this ->getResolver (function () { throw new \RuntimeException (); }));
32
32
@@ -36,27 +36,41 @@ public function testHandleWhenControllerThrowsAnExceptionAndRawIsTrue()
36
36
/**
37
37
* @expectedException \RuntimeException
38
38
*/
39
- public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalseAndNoListenerIsRegistered ()
39
+ public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered ()
40
40
{
41
41
$ kernel = new HttpKernel (new EventDispatcher (), $ this ->getResolver (function () { throw new \RuntimeException (); }));
42
42
43
43
$ kernel ->handle (new Request (), HttpKernelInterface::MASTER_REQUEST , false );
44
44
}
45
45
46
- public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse ()
46
+ public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrueWithAHandlingListener ()
47
47
{
48
48
$ dispatcher = new EventDispatcher ();
49
49
$ dispatcher ->addListener (KernelEvents::EXCEPTION , function ($ event ) {
50
50
$ event ->setResponse (new Response ($ event ->getException ()->getMessage ()));
51
51
});
52
52
53
53
$ kernel = new HttpKernel ($ dispatcher , $ this ->getResolver (function () { throw new \RuntimeException ('foo ' ); }));
54
- $ response = $ kernel ->handle (new Request ());
54
+ $ response = $ kernel ->handle (new Request (), HttpKernelInterface:: MASTER_REQUEST , true );
55
55
56
56
$ this ->assertEquals ('500 ' , $ response ->getStatusCode ());
57
57
$ this ->assertEquals ('foo ' , $ response ->getContent ());
58
58
}
59
59
60
+ /**
61
+ * @expectedException \RuntimeException
62
+ */
63
+ public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrueWithANonHandlingListener ()
64
+ {
65
+ $ dispatcher = new EventDispatcher ();
66
+ $ dispatcher ->addListener (KernelEvents::EXCEPTION , function ($ event ) {
67
+ // should set a response, but does not
68
+ });
69
+
70
+ $ kernel = new HttpKernel ($ dispatcher , $ this ->getResolver (function () { throw new \RuntimeException ('foo ' ); }));
71
+ $ kernel ->handle (new Request (), HttpKernelInterface::MASTER_REQUEST , true );
72
+ }
73
+
60
74
public function testHandleExceptionWithARedirectionResponse ()
61
75
{
62
76
$ dispatcher = new EventDispatcher ();
0 commit comments