You are here

class TestRunnerKernel in Zircon Profile 8.0

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

Kernel for run-tests.sh.

Hierarchy

Expanded class hierarchy of TestRunnerKernel

1 file declares its use of TestRunnerKernel
BrowserTestBase.php in core/modules/simpletest/src/BrowserTestBase.php
Contains \Drupal\simpletest\BrowserTestBase.

File

core/lib/Drupal/Core/Test/TestRunnerKernel.php, line 18
Contains \Drupal\Core\Test\TestRunnerKernel.

Namespace

Drupal\Core\Test
View source
class TestRunnerKernel extends DrupalKernel {

  /**
   * {@inheritdoc}
   */
  public static function createFromRequest(Request $request, $class_loader, $environment = 'test_runner', $allow_dumping = TRUE) {
    return parent::createFromRequest($request, $class_loader, $environment);
  }

  /**
   * {@inheritdoc}
   */
  public function __construct($environment, $class_loader) {
    parent::__construct($environment, $class_loader, FALSE);

    // 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 format_date()/format_interval() cause
    //   a plugin not found exception.
    $this->moduleList = array(
      'system' => 0,
      'simpletest' => 0,
    );
    $this->moduleData = array(
      'system' => new Extension($this->root, 'module', 'core/modules/system/system.info.yml', 'system.module'),
      'simpletest' => new Extension($this->root, 'module', 'core/modules/simpletest/simpletest.info.yml', 'simpletest.module'),
    );
  }

  /**
   * {@inheritdoc}
   */
  public function boot() {

    // Ensure that required Settings exist.
    if (!Settings::getAll()) {
      new Settings(array(
        '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();
    simpletest_classloader_register();

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

    // Create the build/artifacts directory if necessary.
    include_once DRUPAL_ROOT . '/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

Namesort descending Modifiers Type Description Overrides
DrupalKernel::$allowDumping protected property Whether the container can be dumped.
DrupalKernel::$booted protected property Whether the kernel has been booted.
DrupalKernel::$bootstrapContainer protected property Holds the bootstrap container.
DrupalKernel::$bootstrapContainerClass protected property Holds the class used for instantiating the bootstrap container.
DrupalKernel::$classLoader protected property The class loader object.
DrupalKernel::$configStorage protected property Config storage object used for reading enabled modules configuration.
DrupalKernel::$container protected property Holds the container instance.
DrupalKernel::$containerNeedsDumping protected property Whether the container needs to be dumped once booting is complete.
DrupalKernel::$containerNeedsRebuild protected property Whether the container needs to be rebuilt the next time it is initialized.
DrupalKernel::$defaultBootstrapContainerDefinition protected property Holds the default bootstrap container definition.
DrupalKernel::$environment protected property The environment, e.g. 'testing', 'install'.
DrupalKernel::$isEnvironmentInitialized protected static property Whether the PHP environment has been initialized.
DrupalKernel::$moduleData protected property List of available modules and installation profiles.
DrupalKernel::$moduleList protected property Holds the list of enabled modules.
DrupalKernel::$phpArrayDumperClass protected property Holds the class used for dumping the container to a PHP array.
DrupalKernel::$prepared protected property Whether essential services have been set up properly by preHandle().
DrupalKernel::$root protected property The app root.
DrupalKernel::$serviceProviderClasses protected property List of discovered service provider class names or objects.
DrupalKernel::$serviceProviders protected property List of instantiated service provider classes.
DrupalKernel::$serviceYamls protected property List of discovered services.yml pathnames.
DrupalKernel::$sitePath protected property The site directory.
DrupalKernel::addServiceFiles protected function Add service files.
DrupalKernel::attachSynthetic protected function Attach synthetic values on to kernel.
DrupalKernel::bootEnvironment public static function Setup a consistent PHP environment.
DrupalKernel::cacheDrupalContainer protected function Stores the container definition in a cache. 1
DrupalKernel::classLoaderAddMultiplePsr4 protected function Registers a list of namespaces with PSR-4 directories for class loading.
DrupalKernel::compileContainer protected function Compiles a new service container.
DrupalKernel::findSitePath public static function Returns the appropriate site directory for a request.
DrupalKernel::getAppRoot public function Gets the app root. Overrides DrupalKernelInterface::getAppRoot
DrupalKernel::getCachedContainerDefinition public function Returns the cached container definition - if any. Overrides DrupalKernelInterface::getCachedContainerDefinition
DrupalKernel::getConfigStorage protected function Returns the active configuration storage to use during building the container.
DrupalKernel::getContainer public function Gets the current container. Overrides DrupalKernelInterface::getContainer
DrupalKernel::getContainerBuilder protected function Gets a new ContainerBuilder instance used to build the service container.
DrupalKernel::getContainerCacheKey protected function Returns the container cache key based on the environment.
DrupalKernel::getHttpKernel protected function Gets a http kernel from the container
DrupalKernel::getKernelParameters protected function Returns the kernel parameters.
DrupalKernel::getModuleFileNames protected function Gets the file name for each enabled module.
DrupalKernel::getModuleNamespacesPsr4 protected function Gets the PSR-4 base directories for module namespaces.
DrupalKernel::getModulesParameter protected function Returns an array of Extension class parameters for all enabled modules.
DrupalKernel::getServiceProviders public function Returns all registered service providers. Overrides DrupalKernelInterface::getServiceProviders
DrupalKernel::getServicesToPersist protected function Returns service instances to persist from an old container to a new one.
DrupalKernel::getSitePath public function Get the site path. Overrides DrupalKernelInterface::getSitePath
DrupalKernel::handle public function Handles a Request to convert it to a Response. Overrides HttpKernelInterface::handle 1
DrupalKernel::handleException protected function Converts an exception into a response.
DrupalKernel::initializeContainer protected function Initializes the service container. 2
DrupalKernel::initializeRequestGlobals protected function Bootstraps the legacy global request variables.
DrupalKernel::initializeServiceProviders protected function Registers all service providers to the kernel.
DrupalKernel::initializeSettings protected function Locate site path and initialize settings singleton.
DrupalKernel::invalidateContainer public function Invalidate the service container for the next request. Overrides DrupalKernelInterface::invalidateContainer
DrupalKernel::loadLegacyIncludes public function Helper method that loads legacy Drupal include files. Overrides DrupalKernelInterface::loadLegacyIncludes
DrupalKernel::moduleData protected function Returns module data on the filesystem.
DrupalKernel::persistServices protected function Moves persistent service instances into a new container.
DrupalKernel::preHandle public function Helper method that does request related initialization. Overrides DrupalKernelInterface::preHandle
DrupalKernel::prepareLegacyRequest public function Prepare the kernel for handling a request without handling the request. Overrides DrupalKernelInterface::prepareLegacyRequest
DrupalKernel::rebuildContainer public function Force a container rebuild. Overrides DrupalKernelInterface::rebuildContainer
DrupalKernel::setContainer public function Sets the Container. Overrides ContainerAwareInterface::setContainer
DrupalKernel::setSitePath public function Set the current site path. Overrides DrupalKernelInterface::setSitePath
DrupalKernel::setupTrustedHosts protected static function Sets up the lists of trusted HTTP Host headers.
DrupalKernel::shutdown public function Shuts down the kernel. Overrides DrupalKernelInterface::shutdown
DrupalKernel::terminate public function Terminates a request/response cycle. Overrides TerminableInterface::terminate
DrupalKernel::updateModules public function Implements Drupal\Core\DrupalKernelInterface::updateModules(). Overrides DrupalKernelInterface::updateModules
DrupalKernel::validateHostname public static function Validates the hostname supplied from the HTTP request.
DrupalKernel::validateHostnameLength protected static function Validates a hostname length.
HttpKernelInterface::MASTER_REQUEST constant
HttpKernelInterface::SUB_REQUEST constant
TestRunnerKernel::boot public function Boots the current kernel. Overrides DrupalKernel::boot
TestRunnerKernel::createFromRequest public static function Create a DrupalKernel object from a request. Overrides DrupalKernel::createFromRequest
TestRunnerKernel::discoverServiceProviders public function Discovers available serviceProviders. Overrides DrupalKernel::discoverServiceProviders
TestRunnerKernel::__construct public function Constructs a DrupalKernel object. Overrides DrupalKernel::__construct