You are here

public function TestRunnerKernel::boot in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Test/TestRunnerKernel.php \Drupal\Core\Test\TestRunnerKernel::boot()

Boots the current kernel.

Return value

$this

Overrides DrupalKernel::boot

File

core/lib/Drupal/Core/Test/TestRunnerKernel.php, line 55

Class

TestRunnerKernel
Kernel for run-tests.sh.

Namespace

Drupal\Core\Test

Code

public function boot() {

  // Ensure that required Settings exist.
  if (!Settings::getAll()) {
    new Settings([
      'hash_salt' => 'run-tests',
      'container_yamls' => [],
      // If there is no settings.php, then there is no parent site. In turn,
      // there is no public files directory; use a custom public files path.
      'file_public_path' => 'sites/default/files',
    ]);
  }

  // Remove Drupal's error/exception handlers; they are designed for HTML
  // and there is no storage nor a (watchdog) logger here.
  restore_error_handler();
  restore_exception_handler();

  // In addition, ensure that PHP errors are not hidden away in logs.
  ini_set('display_errors', TRUE);
  parent::boot();
  $this
    ->getContainer()
    ->get('module_handler')
    ->loadAll();
  $test_discovery = new TestDiscovery($this
    ->getContainer()
    ->getParameter('app.root'), $this
    ->getContainer()
    ->get('class_loader'));
  $test_discovery
    ->registerTestNamespaces();

  // Register stream wrappers.
  $this
    ->getContainer()
    ->get('stream_wrapper_manager')
    ->register();

  // Create the build/artifacts directory if necessary.
  include_once $this
    ->getAppRoot() . '/core/includes/file.inc';
  if (!is_dir('public://simpletest')) {
    mkdir('public://simpletest', 0777, TRUE);
  }
}