You are here

public function HttpKernelTest::testHandleExceptionWithARedirectionResponse in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-kernel/Tests/HttpKernelTest.php \Symfony\Component\HttpKernel\Tests\HttpKernelTest::testHandleExceptionWithARedirectionResponse()

File

vendor/symfony/http-kernel/Tests/HttpKernelTest.php, line 79

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