class TestRunnerKernel in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Test/TestRunnerKernel.php \Drupal\Core\Test\TestRunnerKernel
Kernel for run-tests.sh.
Hierarchy
- class \Drupal\Core\DrupalKernel implements \Symfony\Component\HttpKernel\TerminableInterface, DrupalKernelInterface uses InstallerRedirectTrait
- class \Drupal\Core\Test\TestRunnerKernel
Expanded class hierarchy of TestRunnerKernel
2 files declare their use of TestRunnerKernel
- TestRunnerKernelTest.php in core/
tests/ Drupal/ Tests/ Core/ Test/ TestRunnerKernelTest.php - UpdatePathTestBase.php in core/
tests/ Drupal/ FunctionalTests/ Update/ UpdatePathTestBase.php
File
- core/
lib/ Drupal/ Core/ Test/ TestRunnerKernel.php, line 14
Namespace
Drupal\Core\TestView source
class TestRunnerKernel extends DrupalKernel {
/**
* {@inheritdoc}
*/
public static function createFromRequest(Request $request, $class_loader, $environment = 'test_runner', $allow_dumping = TRUE, $app_root = NULL) {
return parent::createFromRequest($request, $class_loader, $environment, $allow_dumping, $app_root);
}
/**
* {@inheritdoc}
*/
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'];
}
}
/**
* {@inheritdoc}
*/
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);
}
}
/**
* {@inheritdoc}
*/
public function discoverServiceProviders() {
parent::discoverServiceProviders();
// The test runner does not require an installed Drupal site to exist.
// Therefore, its environment is identical to that of the early installer.
$this->serviceProviderClasses['app']['Test'] = 'Drupal\\Core\\Installer\\InstallerServiceProvider';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalKernel:: |
protected | property | Whether the container can be dumped. | |
DrupalKernel:: |
protected | property | Whether the kernel has been booted. | |
DrupalKernel:: |
protected | property | Holds the bootstrap container. | |
DrupalKernel:: |
protected | property | Holds the class used for instantiating the bootstrap container. | |
DrupalKernel:: |
protected | property | The class loader object. | |
DrupalKernel:: |
protected | property | Config storage object used for reading enabled modules configuration. | |
DrupalKernel:: |
protected | property | Holds the container instance. | |
DrupalKernel:: |
protected | property | Whether the container needs to be dumped once booting is complete. | |
DrupalKernel:: |
protected | property | Whether the container needs to be rebuilt the next time it is initialized. | |
DrupalKernel:: |
protected | property | Holds the default bootstrap container definition. | |
DrupalKernel:: |
protected | property | The environment, e.g. 'testing', 'install'. | |
DrupalKernel:: |
protected static | property | Whether the PHP environment has been initialized. | |
DrupalKernel:: |
protected | property | List of available modules and installation profiles. | |
DrupalKernel:: |
protected | property | Holds the list of enabled modules. | |
DrupalKernel:: |
protected | property | Holds the class used for dumping the container to a PHP array. | |
DrupalKernel:: |
protected | property | Whether essential services have been set up properly by preHandle(). | |
DrupalKernel:: |
protected | property | The app root. | |
DrupalKernel:: |
protected | property | List of discovered service provider class names or objects. | |
DrupalKernel:: |
protected | property | List of instantiated service provider classes. | |
DrupalKernel:: |
protected | property | List of discovered services.yml pathnames. | |
DrupalKernel:: |
protected | property | The site directory. | |
DrupalKernel:: |
protected | function | Add service files. | |
DrupalKernel:: |
protected | function | Attach synthetic values on to kernel. | |
DrupalKernel:: |
public static | function | Setup a consistent PHP environment. | |
DrupalKernel:: |
protected | function | Stores the container definition in a cache. | 1 |
DrupalKernel:: |
protected | function | Registers a list of namespaces with PSR-4 directories for class loading. | |
DrupalKernel:: |
protected | function | Compiles a new service container. | |
DrupalKernel:: |
public static | function | Returns the appropriate site directory for a request. | |
DrupalKernel:: |
public | function |
Gets the app root. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
public | function |
Returns the cached container definition - if any. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
protected | function | Returns the active configuration storage to use during building the container. | 1 |
DrupalKernel:: |
public | function |
Gets the current container. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
protected | function | Gets a new ContainerBuilder instance used to build the service container. | |
DrupalKernel:: |
protected | function | Returns the container cache key based on the environment. | |
DrupalKernel:: |
protected | function | Gets a http kernel from the container. | |
DrupalKernel:: |
protected | function | Gets the active install profile. | 1 |
DrupalKernel:: |
protected | function | Returns the kernel parameters. | |
DrupalKernel:: |
protected | function | Gets the file name for each enabled module. | |
DrupalKernel:: |
protected | function | Gets the PSR-4 base directories for module namespaces. | |
DrupalKernel:: |
protected | function | Returns an array of Extension class parameters for all enabled modules. | |
DrupalKernel:: |
public | function |
Returns all registered service providers. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
protected | function | Returns service instances to persist from an old container to a new one. | |
DrupalKernel:: |
public | function |
Get the site path. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
protected static | function | Determine the application root directory based on this file's location. | |
DrupalKernel:: |
public | function | 1 | |
DrupalKernel:: |
protected | function | Converts an exception into a response. | |
DrupalKernel:: |
protected | function | Initializes the service container. | 2 |
DrupalKernel:: |
protected | function | Bootstraps the legacy global request variables. | |
DrupalKernel:: |
protected | function | Registers all service providers to the kernel. | |
DrupalKernel:: |
protected | function | Locate site path and initialize settings singleton. | |
DrupalKernel:: |
public | function |
Invalidate the service container for the next request. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
public | function |
Helper method that loads legacy Drupal include files. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
protected | function | Returns module data on the filesystem. | |
DrupalKernel:: |
protected | function | Moves persistent service instances into a new container. | |
DrupalKernel:: |
public | function |
Helper method that does request related initialization. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
public | function |
Force a container rebuild. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
public | function | ||
DrupalKernel:: |
public | function |
Set the current site path. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
protected static | function | Sets up the lists of trusted HTTP Host headers. | |
DrupalKernel:: |
public | function |
Shuts down the kernel. Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
public | function | ||
DrupalKernel:: |
public | function |
Implements Drupal\Core\DrupalKernelInterface::updateModules(). Overrides DrupalKernelInterface:: |
|
DrupalKernel:: |
public static | function | Validates the hostname supplied from the HTTP request. | |
DrupalKernel:: |
protected static | function | Validates a hostname length. | |
DrupalKernelInterface:: |
constant | Event fired when the service container finished initializing in subrequest. | ||
InstallerRedirectTrait:: |
protected | function | Returns whether the current PHP process runs on CLI. | |
InstallerRedirectTrait:: |
protected | function | Determines if an exception handler should redirect to the installer. | |
TestRunnerKernel:: |
public | function |
Boots the current kernel. Overrides DrupalKernel:: |
|
TestRunnerKernel:: |
public static | function |
Create a DrupalKernel object from a request. Overrides DrupalKernel:: |
|
TestRunnerKernel:: |
public | function |
Discovers available serviceProviders. Overrides DrupalKernel:: |
|
TestRunnerKernel:: |
public | function |
Constructs a DrupalKernel object. Overrides DrupalKernel:: |