Commit 39d126b2 authored by webchick's avatar webchick

Issue #2257427 by sun: Run-tests.sh builds + rebuilds two kernels from scratch...

Issue #2257427 by sun: Run-tests.sh builds + rebuilds two kernels from scratch for every PHP process.
parent ac31f29d
<?php
/**
* @file
* Contains \Drupal\Core\Test\TestKernel.
*/
namespace Drupal\Core\Test;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Installer\InstallerServiceProvider;
use Composer\Autoload\ClassLoader;
/**
* Kernel for run-tests.sh.
*/
class TestKernel extends DrupalKernel {
/**
* Constructs a TestKernel.
*
* @param \Composer\Autoload\ClassLoader $class_loader
* The classloader.
*/
public function __construct(ClassLoader $class_loader) {
parent::__construct('test_runner', $class_loader, FALSE);
// Prime the module list and corresponding Extension objects.
// @todo Remove System module. Needed because \Drupal\Core\Datetime\Date
// 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('module', 'core/modules/system/system.info.yml', 'system.module'),
'simpletest' => new Extension('module', 'core/modules/simpletest/simpletest.info.yml', 'simpletest.module'),
);
}
/**
* {@inheritdoc}
*/
public function discoverServiceProviders() {
$providers = 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[] = 'Drupal\Core\Installer\InstallerServiceProvider';
$providers[] = new InstallerServiceProvider();
return $providers;
}
}
......@@ -7,8 +7,8 @@
use Drupal\Component\Utility\Timer;
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
use Drupal\Core\Test\TestKernel;
use Symfony\Component\HttpFoundation\Request;
require_once __DIR__ . '/../vendor/autoload.php';
......@@ -364,9 +364,6 @@ function simpletest_script_bootstrap() {
require_once $include;
}
// Replace services with in-memory and null implementations.
$GLOBALS['conf']['container_service_providers']['InstallerServiceProvider'] = 'Drupal\Core\Installer\InstallerServiceProvider';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
// Remove Drupal's error/exception handlers; they are designed for HTML
......@@ -384,7 +381,7 @@ function simpletest_script_bootstrap() {
));
}
$kernel = new DrupalKernel('testing', drupal_classloader(), FALSE);
$kernel = new TestKernel(drupal_classloader());
$kernel->boot();
$request = Request::createFromGlobals();
......@@ -394,14 +391,7 @@ function simpletest_script_bootstrap() {
$container->get('request_stack')->push($request);
$module_handler = $container->get('module_handler');
// @todo Remove System module. Only needed because \Drupal\Core\Datetime\Date
// has a (needless) dependency on the 'date_format' entity, so calls to
// format_date()/format_interval() cause a plugin not found exception.
$module_handler->addModule('system', 'core/modules/system');
$module_handler->addModule('simpletest', 'core/modules/simpletest');
$module_handler->loadAll();
$module_filenames = $module_handler->getModuleList();
$kernel->updateModules($module_filenames, $module_filenames);
simpletest_classloader_register();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment