diff --git a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php index 8f145dd..89ed6d2 100644 --- a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php +++ b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php @@ -127,7 +127,7 @@ public function testTestingThroughUI() { $tests = array( // A KernelTestBase test. - 'Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest', + 'Drupal\system\Tests\DrupalKernel\DrupalKernelTest', // A PHPUnit unit test. 'Drupal\Tests\action\Unit\Menu\ActionLocalTasksTest', // A PHPUnit functional test. diff --git a/core/modules/simpletest/src/Tests/SimpleTestTest.php b/core/modules/simpletest/src/Tests/SimpleTestTest.php index 2ae17d4..290403b 100644 --- a/core/modules/simpletest/src/Tests/SimpleTestTest.php +++ b/core/modules/simpletest/src/Tests/SimpleTestTest.php @@ -78,8 +78,8 @@ function simpletest_test_stub_settings_function() {} } EOD; - file_put_contents($this->siteDirectory. '/' . 'settings.testing.php', $php); - // @see \Drupal\KernelTests\Core\DrupalKernel\DrupalKernelSiteTest + file_put_contents($this->siteDirectory . '/' . 'settings.testing.php', $php); + // @see \Drupal\system\Tests\DrupalKernel\DrupalKernelSiteTest $class = __CLASS__; $yaml = <<root = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__)))))); - $this->setSetting('php_storage', array('service_container' => array( + // DrupalKernel relies on global $config_directories and requires those + // directories to exist. Therefore, create the directories, but do not + // invoke KernelTestBase::setUp(), since that would set up further + // environment aspects, which would distort this test, because it tests + // the DrupalKernel (re-)building itself. + $this->prepareConfigDirectories(); + + $this->settingsSet('php_storage', array('service_container' => array( 'bin' => 'service_container', 'class' => 'Drupal\Component\PhpStorage\MTimeProtectedFileStorage', - 'directory' => $this->root . '/' . $this->publicFilesDirectory . '/php', - 'secret' => 'test-secret', + 'directory' => DRUPAL_ROOT . '/' . $this->publicFilesDirectory . '/php', + 'secret' => Settings::getHashSalt(), ))); } /** + * {@inheritdoc} + */ + protected function prepareConfigDirectories() { + \Drupal::setContainer($this->originalContainer); + parent::prepareConfigDirectories(); + \Drupal::unsetContainer(); + } + + /** * Build a kernel for testings. * * Because the bootstrap is in DrupalKernel::boot and that involved loading @@ -41,10 +56,10 @@ protected function setUp() { */ protected function getTestKernel(Request $request, array $modules_enabled = NULL) { // Manually create kernel to avoid replacing settings. - $class_loader = require $this->root . '/autoload.php'; + $class_loader = require DRUPAL_ROOT . '/autoload.php'; $kernel = DrupalKernel::createFromRequest($request, $class_loader, 'testing'); - $this->setSetting('container_yamls', []); - $this->setSetting('hash_salt', $this->databasePrefix); + $this->settingsSet('container_yamls', []); + $this->settingsSet('hash_salt', $this->databasePrefix); if (isset($modules_enabled)) { $kernel->updateModules($modules_enabled); } @@ -138,7 +153,7 @@ public function testCompileDIC() { */ public function testRepeatedBootWithDifferentEnvironment() { $request = Request::createFromGlobals(); - $class_loader = require $this->root . '/autoload.php'; + $class_loader = require DRUPAL_ROOT . '/autoload.php'; $environments = [ 'testing1', @@ -149,8 +164,8 @@ public function testRepeatedBootWithDifferentEnvironment() { foreach ($environments as $environment) { $kernel = DrupalKernel::createFromRequest($request, $class_loader, $environment); - $this->setSetting('container_yamls', []); - $this->setSetting('hash_salt', $this->databasePrefix); + $this->settingsSet('container_yamls', []); + $this->settingsSet('hash_salt', $this->databasePrefix); $kernel->boot(); }