public function HttpKernelTest::testHandleWhenAnExceptionIsHandledWithASpecificStatusCode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-kernel/Tests/HttpKernelTest.php \Symfony\Component\HttpKernel\Tests\HttpKernelTest::testHandleWhenAnExceptionIsHandledWithASpecificStatusCode()
@dataProvider getStatusCodes
File
- vendor/
symfony/ http-kernel/ Tests/ HttpKernelTest.php, line 110
Class
Namespace
Symfony\Component\HttpKernel\TestsCode
public function testHandleWhenAnExceptionIsHandledWithASpecificStatusCode($responseStatusCode, $expectedStatusCode) {
$dispatcher = new EventDispatcher();
$dispatcher
->addListener(KernelEvents::EXCEPTION, function ($event) use ($responseStatusCode, $expectedStatusCode) {
$event
->setResponse(new Response('', $responseStatusCode, array(
'X-Status-Code' => $expectedStatusCode,
)));
});
$kernel = new HttpKernel($dispatcher, $this
->getResolver(function () {
throw new \RuntimeException();
}));
$response = $kernel
->handle(new Request());
$this
->assertEquals($expectedStatusCode, $response
->getStatusCode());
$this
->assertFalse($response->headers
->has('X-Status-Code'));
}