function StackedHttpKernelTest::testTerminate

Tests that stacked kernel invokes the terminate call in all middlewares.

File

core/tests/Drupal/Tests/Core/StackMiddleware/StackedHttpKernelTest.php, line 63

Class

StackedHttpKernelTest
Tests Drupal\Core\StackMiddleware\StackedHttpKernel.

Namespace

Drupal\Tests\Core\StackMiddleware

Code

public function testTerminate() : void {
  $request = new Request();
  $response = new Response();
  $basicKernel = $this->createMockForIntersectionOfInterfaces([
    HttpKernelInterface::class,
    TerminableInterface::class,
  ]);
  $basicKernel->expects($this->once())
    ->method('terminate')
    ->with($request, $response);
  $outer = $this->createMock(HttpKernelInterface::class);
  $middle = $this->createMockForIntersectionOfInterfaces([
    HttpKernelInterface::class,
    TerminableInterface::class,
  ]);
  $middle->expects($this->once())
    ->method('terminate')
    ->with($request, $response);
  $inner = $this->createMock(HttpKernelInterface::class);
  $middlewares = new \ArrayIterator([
    $outer,
    $middle,
    $inner,
    $basicKernel,
  ]);
  $stack = new StackedHttpKernel($outer, $middlewares);
  $stack->terminate($request, $response);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.