public function HttpKernelTest::testHandleWhenAnExceptionIsHandledWithASpecificStatusCode

@dataProvider getStatusCodes

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php, line 102

Class

HttpKernelTest

Namespace

Symfony\Component\HttpKernel\Tests

Code

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'));
}