function TestRunnerKernel::boot

Same name and namespace 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. 10 core/lib/Drupal/Core/Test/TestRunnerKernel.php \Drupal\Core\Test\TestRunnerKernel::boot()

Overrides DrupalKernel::boot

File

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

Class

TestRunnerKernel
Defines a kernel used for running Functional tests and <a href="/api/drupal/core%21scripts%21run-tests.sh/11.x" title="Script for running tests on DrupalCI." class="local">run-tests.sh</a>.

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.
    $currentErrorHandler = Error::currentErrorHandler();
    if (is_string($currentErrorHandler) && $currentErrorHandler === '_drupal_error_handler') {
        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.