public function HttpKernelTest::testHandleExceptionWithARedirectionResponse

File

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

Class

HttpKernelTest

Namespace

Symfony\Component\HttpKernel\Tests

Code

public function testHandleExceptionWithARedirectionResponse() {
  $dispatcher = new EventDispatcher();
  $dispatcher
    ->addListener(KernelEvents::EXCEPTION, function ($event) {
    $event
      ->setResponse(new RedirectResponse('/login', 301));
  });
  $kernel = new HttpKernel($dispatcher, $this
    ->getResolver(function () {
    throw new AccessDeniedHttpException();
  }));
  $response = $kernel
    ->handle(new Request());
  $this
    ->assertEquals('301', $response
    ->getStatusCode());
  $this
    ->assertEquals('/login', $response->headers
    ->get('Location'));
}