Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b1a7414

Browse filesBrowse files
committed
add tests
1 parent f55c39d commit b1a7414
Copy full SHA for b1a7414

File tree

2 files changed

+43
-0
lines changed
Filter options

2 files changed

+43
-0
lines changed

‎src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Symfony\Component\HttpKernel\HttpKernel;
2929
use Symfony\Component\HttpKernel\HttpKernelInterface;
3030
use Symfony\Component\HttpKernel\KernelEvents;
31+
use Throwable;
3132

3233
class HttpKernelTest extends TestCase
3334
{
@@ -39,6 +40,45 @@ public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue()
3940
$kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true);
4041
}
4142

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 testHandleWhenControllerThrowsAnExceptionAndCatchIsFalse()
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 testHandleWhenControllerThrowsAnThrowable()
70+
{
71+
$requestStack = new RequestStack();
72+
$kernel = $this->getHttpKernel(new EventDispatcher(), function () { require __DIR__.'/broken_script.php'; }, $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+
4282
public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered()
4383
{
4484
$this->expectException(\RuntimeException::class);
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
syntax error

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.