public function HttpKernelTest::testHandleWhenControllerThrowsAnExceptionAndRawIsFalse

File

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

Class

HttpKernelTest

Namespace

Symfony\Component\HttpKernel\Tests

Code

public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse() {
  $dispatcher = new EventDispatcher();
  $dispatcher
    ->addListener(KernelEvents::EXCEPTION, function ($event) {
    $event
      ->setResponse(new Response($event
      ->getException()
      ->getMessage()));
  });
  $kernel = new HttpKernel($dispatcher, $this
    ->getResolver(function () {
    throw new \RuntimeException('foo');
  }));
  $response = $kernel
    ->handle(new Request());
  $this
    ->assertEquals('500', $response
    ->getStatusCode());
  $this
    ->assertEquals('foo', $response
    ->getContent());
}