You are here

public function ContainerRebuildWebTest::testContainerInvalidation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/DrupalKernel/ContainerRebuildWebTest.php \Drupal\system\Tests\DrupalKernel\ContainerRebuildWebTest::testContainerInvalidation()

Tests container invalidation.

File

core/modules/system/src/Tests/DrupalKernel/ContainerRebuildWebTest.php, line 41
Contains \Drupal\system\Tests\DrupalKernel\ContainerRebuildWebTest.

Class

ContainerRebuildWebTest
Ensures that the container rebuild works as expected.

Namespace

Drupal\system\Tests\DrupalKernel

Code

public function testContainerInvalidation() {

  // Ensure that parameter is not set.
  $this
    ->drupalGet('<front>');
  $this
    ->assertHeader('container_rebuild_test_parameter', FALSE);

  // Ensure that after setting the parameter, without a container rebuild the
  // parameter is still not set.
  $this
    ->writeSettings([
    'settings' => [
      'container_rebuild_test_parameter' => (object) [
        'value' => 'rebuild_me_please',
        'required' => TRUE,
      ],
    ],
  ]);
  $this
    ->drupalGet('<front>');
  $this
    ->assertHeader('container_rebuild_test_parameter', FALSE);

  // Ensure that after container invalidation the parameter is set.
  \Drupal::service('kernel')
    ->invalidateContainer();
  $this
    ->drupalGet('<front>');
  $this
    ->assertHeader('container_rebuild_test_parameter', 'rebuild_me_please');
}