function TestRunnerKernel::boot

Same name in other branches
  1. 9 core/lib/Drupal/Core/Test/TestRunnerKernel.php \Drupal\Core\Test\TestRunnerKernel::boot()
  2. 8.9.x core/lib/Drupal/Core/Test/TestRunnerKernel.php \Drupal\Core\Test\TestRunnerKernel::boot()
  3. 11.x core/lib/Drupal/Core/Test/TestRunnerKernel.php \Drupal\Core\Test\TestRunnerKernel::boot()

Overrides DrupalKernel::boot

File

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

Class

TestRunnerKernel
Defines a kernel used for running Functional tests and 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.
    if (!is_dir('public://simpletest') && !@mkdir('public://simpletest', 0777, TRUE) && !is_dir('public://simpletest')) {
        throw new \RuntimeException('Unable to create directory: public://simpletest');
    }
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.