public function HttpKernelTest::testTerminate

File

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

Class

HttpKernelTest

Namespace

Symfony\Component\HttpKernel\Tests

Code

public function testTerminate() {
  $dispatcher = new EventDispatcher();
  $kernel = new HttpKernel($dispatcher, $this
    ->getResolver());
  $dispatcher
    ->addListener(KernelEvents::TERMINATE, function ($event) use (&$called, &$capturedKernel, &$capturedRequest, &$capturedResponse) {
    $called = true;
    $capturedKernel = $event
      ->getKernel();
    $capturedRequest = $event
      ->getRequest();
    $capturedResponse = $event
      ->getResponse();
  });
  $kernel
    ->terminate($request = Request::create('/'), $response = new Response());
  $this
    ->assertTrue($called);
  $this
    ->assertEquals($kernel, $capturedKernel);
  $this
    ->assertEquals($request, $capturedRequest);
  $this
    ->assertEquals($response, $capturedResponse);
}