@@ -39,6 +39,45 @@ public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue()
3939 $ kernel ->handle (new Request (), HttpKernelInterface::MASTER_REQUEST , true );
4040 }
4141
42+ public function testRequestStackIsNotBrokenWhenControllerThrowsAnExceptionAndCatchIsTrue ()
43+ {
44+ $ requestStack = new RequestStack ();
45+ $ kernel = $ this ->getHttpKernel (new EventDispatcher (), function () { throw new \RuntimeException (); }, $ requestStack );
46+
47+ try {
48+ $ kernel ->handle (new Request (), HttpKernelInterface::MASTER_REQUEST , true );
49+ } catch (\Throwable $ exception ) {
50+ }
51+
52+ self ::assertNull ($ requestStack ->getCurrentRequest ());
53+ }
54+
55+ public function testRequestStackIsNotBrokenWhenControllerThrowsAnExceptionAndCatchIsFalse ()
56+ {
57+ $ requestStack = new RequestStack ();
58+ $ kernel = $ this ->getHttpKernel (new EventDispatcher (), function () { throw new \RuntimeException (); }, $ requestStack );
59+
60+ try {
61+ $ kernel ->handle (new Request (), HttpKernelInterface::MASTER_REQUEST , false );
62+ } catch (\Throwable $ exception ) {
63+ }
64+
65+ self ::assertNull ($ requestStack ->getCurrentRequest ());
66+ }
67+
68+ public function testRequestStackIsNotBrokenWhenControllerThrowsAnThrowable ()
69+ {
70+ $ requestStack = new RequestStack ();
71+ $ kernel = $ this ->getHttpKernel (new EventDispatcher (), function () { throw new \Error (); }, $ requestStack );
72+
73+ try {
74+ $ kernel ->handle (new Request (), HttpKernelInterface::MASTER_REQUEST , true );
75+ } catch (\Throwable $ exception ) {
76+ }
77+
78+ self ::assertNull ($ requestStack ->getCurrentRequest ());
79+ }
80+
4281 public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered ()
4382 {
4483 $ this ->expectException (\RuntimeException::class);
0 commit comments