You are here

public function DrupalKernelTest::testRepeatedBootWithDifferentEnvironment in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php \Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest::testRepeatedBootWithDifferentEnvironment()

Tests repeated loading of compiled DIC with different environment.

File

core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php, line 147

Class

DrupalKernelTest
Tests DIC compilation to disk.

Namespace

Drupal\KernelTests\Core\DrupalKernel

Code

public function testRepeatedBootWithDifferentEnvironment() {
  $request = Request::createFromGlobals();
  $class_loader = (require $this->root . '/autoload.php');
  $environments = [
    'testing1',
    'testing1',
    'testing2',
    'testing2',
  ];
  foreach ($environments as $environment) {
    $kernel = DrupalKernel::createFromRequest($request, $class_loader, $environment);
    $this
      ->setSetting('container_yamls', []);
    $this
      ->setSetting('hash_salt', $this->databasePrefix);
    $this
      ->assertInstanceOf(DrupalKernelInterface::class, $kernel
      ->boot(), "Environment {$environment} should boot.");
  }
}