You are here

public function TestRunnerKernel::__construct in Drupal 9

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

Constructs a DrupalKernel object.

Parameters

string $environment: String indicating the environment, e.g. 'prod' or 'dev'.

$class_loader: The class loader. Normally \Composer\Autoload\ClassLoader, as included by the front controller, but may also be decorated.

bool $allow_dumping: (optional) FALSE to stop the container from being written to or read from disk. Defaults to TRUE.

string $app_root: (optional) The path to the application root as a string. If not supplied, the application root will be computed.

Overrides DrupalKernel::__construct

File

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

Class

TestRunnerKernel
Kernel for run-tests.sh.

Namespace

Drupal\Core\Test

Code

public function __construct($environment, $class_loader, $allow_dumping = FALSE, $app_root = NULL) {

  // Force $allow_dumping to FALSE, because the test runner kernel should
  // always have to rebuild its container, and potentially avoid isolation
  // issues against the tests.
  parent::__construct($environment, $class_loader, FALSE, $app_root);

  // Prime the module list and corresponding Extension objects.
  // @todo Remove System module. Needed because
  //   \Drupal\Core\Datetime\DateFormatter has a (needless) dependency on the
  //   'date_format' entity, so calls to DateFormatter::format() and
  //   DateFormatter::formatInterval() cause a plugin not found exception.
  $this->moduleList = [
    'system' => 0,
  ];
  $this->moduleData = [
    'system' => new Extension($this->root, 'module', 'core/modules/system/system.info.yml', 'system.module'),
  ];

  // In order to support Simpletest in Drupal 9 conditionally include the
  // module.
  $extensions = (new ExtensionDiscovery($this->root, FALSE, [], 'ignore_site_path_does_not_exist'))
    ->scan('module', FALSE);
  if (isset($extensions['simpletest'])) {
    $this->moduleList['simpletest'] = 0;
    $this->moduleData['simpletest'] = $extensions['simpletest'];
  }
}