|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\HttpKernel\Tests;
|
13 | 13 |
|
| 14 | +use Error; |
14 | 15 | use PHPUnit\Framework\TestCase;
|
15 | 16 | use Symfony\Component\EventDispatcher\EventDispatcher;
|
16 | 17 | use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
@@ -39,6 +40,45 @@ public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue()
|
39 | 40 | $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true);
|
40 | 41 | }
|
41 | 42 |
|
| 43 | + public function testRequestStackIsNotBrokenWhenControllerThrowsAnExceptionAndCatchIsTrue() |
| 44 | + { |
| 45 | + $requestStack = new RequestStack(); |
| 46 | + $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }, $requestStack); |
| 47 | + |
| 48 | + try { |
| 49 | + $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); |
| 50 | + } catch (\Throwable $exception) { |
| 51 | + } |
| 52 | + |
| 53 | + self::assertNull($requestStack->getCurrentRequest()); |
| 54 | + } |
| 55 | + |
| 56 | + public function testRequestStackIsNotBrokenWhenControllerThrowsAnExceptionAndCatchIsFalse() |
| 57 | + { |
| 58 | + $requestStack = new RequestStack(); |
| 59 | + $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }, $requestStack); |
| 60 | + |
| 61 | + try { |
| 62 | + $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false); |
| 63 | + } catch (\Throwable $exception) { |
| 64 | + } |
| 65 | + |
| 66 | + self::assertNull($requestStack->getCurrentRequest()); |
| 67 | + } |
| 68 | + |
| 69 | + public function testRequestStackIsNotBrokenWhenControllerThrowsAnThrowable() |
| 70 | + { |
| 71 | + $requestStack = new RequestStack(); |
| 72 | + $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new Error(); }, $requestStack); |
| 73 | + |
| 74 | + try { |
| 75 | + $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); |
| 76 | + } catch (\Throwable $exception) { |
| 77 | + } |
| 78 | + |
| 79 | + self::assertNull($requestStack->getCurrentRequest()); |
| 80 | + } |
| 81 | + |
42 | 82 | public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered()
|
43 | 83 | {
|
44 | 84 | $this->expectException(\RuntimeException::class);
|
|
0 commit comments