function StackedHttpKernelTest::testDeprecatedMiddlewaresArgument

Tests that stacked kernel is constructed with a list of middlewares.

Attributes

#[IgnoreDeprecations]

File

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

Class

StackedHttpKernelTest
Tests Drupal\Core\StackMiddleware\StackedHttpKernel.

Namespace

Drupal\Tests\Core\StackMiddleware

Code

public function testDeprecatedMiddlewaresArgument() : void {
  $request = new Request();
  $expected = new Response();
  $basicKernel = $this->createMock(HttpKernelInterface::class);
  $basicKernel->expects($this->once())
    ->method('handle')
    ->with($request, HttpKernelInterface::MAIN_REQUEST, TRUE)
    ->willReturn($expected);
  $this->expectDeprecation('Calling Drupal\\Core\\StackMiddleware\\StackedHttpKernel::__construct() with an array of $middlewares is deprecated in drupal:11.3.0 and it will throw an error in drupal:12.0.0. Pass in a lazy iterator instead. See https://www.drupal.org/node/3538740');
  $stack = new StackedHttpKernel($basicKernel, [
    $basicKernel,
  ]);
  $actual = $stack->handle($request);
  $this->assertSame($expected, $actual);
}

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