protected function KernelTestBase::bootEnvironment in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::bootEnvironment()
 - 9 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::bootEnvironment()
 
Bootstraps a basic test environment.
Should not be called by tests. Only visible for DrupalKernel integration tests.
@internal
See also
\Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest
2 calls to KernelTestBase::bootEnvironment()
- DrupalKernelTest::setUp in core/
tests/ Drupal/ KernelTests/ Core/ DrupalKernel/ DrupalKernelTest.php  - KernelTestBase::setUp in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php  
File
- core/
tests/ Drupal/ KernelTests/ KernelTestBase.php, line 263  
Class
- KernelTestBase
 - Base class for functional integration tests.
 
Namespace
Drupal\KernelTestsCode
protected function bootEnvironment() {
  \Drupal::unsetContainer();
  $this->classLoader = (require $this->root . '/autoload.php');
  // Set up virtual filesystem.
  Database::addConnectionInfo('default', 'test-runner', $this
    ->getDatabaseConnectionInfo()['default']);
  $test_db = new TestDatabase();
  $this->siteDirectory = $test_db
    ->getTestSitePath();
  // Ensure that all code that relies on drupal_valid_test_ua() can still be
  // safely executed. This primarily affects the (test) site directory
  // resolution (used by e.g. LocalStream and PhpStorage).
  $this->databasePrefix = $test_db
    ->getDatabasePrefix();
  drupal_valid_test_ua($this->databasePrefix);
  $settings = [
    'hash_salt' => static::class,
    'file_public_path' => $this->siteDirectory . '/files',
    // Disable Twig template caching/dumping.
    'twig_cache' => FALSE,
  ];
  new Settings($settings);
  $this
    ->setUpFilesystem();
  foreach (Database::getAllConnectionInfo() as $key => $targets) {
    Database::removeConnection($key);
  }
  Database::addConnectionInfo('default', 'default', $this
    ->getDatabaseConnectionInfo()['default']);
}