public function HttpKernelTest::testHandleHttpException

File

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

Class

HttpKernelTest

Namespace

Symfony\Component\HttpKernel\Tests

Code

public function testHandleHttpException() {
  $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 MethodNotAllowedHttpException(array(
      'POST',
    ));
  }));
  $response = $kernel
    ->handle(new Request());
  $this
    ->assertEquals('405', $response
    ->getStatusCode());
  $this
    ->assertEquals('POST', $response->headers
    ->get('Allow'));
}