You are here

public function StackKernelIntegrationTest::testLazyLateMiddlewares in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/HttpKernel/StackKernelIntegrationTest.php \Drupal\system\Tests\HttpKernel\StackKernelIntegrationTest::testLazyLateMiddlewares()

Tests that late middlewares are automatically flagged lazy.

File

core/modules/system/src/Tests/HttpKernel/StackKernelIntegrationTest.php, line 55
Contains \Drupal\system\Tests\HttpKernel\StackKernelIntegrationTest.

Class

StackKernelIntegrationTest
Tests the stacked kernel functionality.

Namespace

Drupal\system\Tests\HttpKernel

Code

public function testLazyLateMiddlewares() {
  $this
    ->assertFalse($this->container
    ->getDefinition('http_middleware.reverse_proxy')
    ->isLazy(), 'lazy flag on http_middleware.reverse_proxy definition is not set');
  $this
    ->assertFalse($this->container
    ->getDefinition('http_middleware.kernel_pre_handle')
    ->isLazy(), 'lazy flag on http_middleware.kernel_pre_handle definition is not set');
  $this
    ->assertFalse($this->container
    ->getDefinition('http_middleware.session')
    ->isLazy(), 'lazy flag on http_middleware.session definition is not set');
  $this
    ->assertFalse($this->container
    ->getDefinition('http_kernel.basic')
    ->isLazy(), 'lazy flag on http_kernel.basic definition is not set');
  \Drupal::service('module_installer')
    ->install([
    'page_cache',
  ]);
  $this->container = $this->kernel
    ->rebuildContainer();
  $this
    ->assertFalse($this->container
    ->getDefinition('http_middleware.reverse_proxy')
    ->isLazy(), 'lazy flag on http_middleware.reverse_proxy definition is not set');
  $this
    ->assertFalse($this->container
    ->getDefinition('http_middleware.page_cache')
    ->isLazy(), 'lazy flag on http_middleware.page_cache definition is not set');
  $this
    ->assertTrue($this->container
    ->getDefinition('http_middleware.kernel_pre_handle')
    ->isLazy(), 'lazy flag on http_middleware.kernel_pre_handle definition is automatically set if page_cache is enabled.');
  $this
    ->assertTrue($this->container
    ->getDefinition('http_middleware.session')
    ->isLazy(), 'lazy flag on http_middleware.session definition is automatically set if page_cache is enabled.');
  $this
    ->assertTrue($this->container
    ->getDefinition('http_kernel.basic')
    ->isLazy(), 'lazy flag on http_kernel.basic definition is automatically set if page_cache is enabled.');
}