diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 87ba4a5..d180a56 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -302,7 +302,7 @@ function drupal_override_server_variables($variables = array()) { // Replace elements of the $_SERVER array, as appropriate. $request->server->replace($variables + $server_vars + $defaults); - // @todo remove once conf_path() no longer uses $_SERVER. + // @todo remove once Site::determinePath() no longer uses $_SERVER. $_SERVER = $request->server->all(); } diff --git a/core/lib/Drupal/Core/Site/Site.php b/core/lib/Drupal/Core/Site/Site.php index 39c7057..572400e 100644 --- a/core/lib/Drupal/Core/Site/Site.php +++ b/core/lib/Drupal/Core/Site/Site.php @@ -145,8 +145,11 @@ public static function tearDownTest() { if (!isset(self::$original)) { throw new \RuntimeException('No original Site to revert to. Missing invocation of Site::setUpTest()?'); } - if (drupal_valid_test_ua()) { - throw new \BadMethodCallException('Site is executing a test.'); + // Do not allow to restore original Site singleton in a test environment, + // unless we are testing the test environment setup and teardown itself. + // @see \Drupal\simpletest\Tests\BrokenSetUpTest + if (drupal_valid_test_ua() && !DRUPAL_TEST_IN_CHILD_SITE) { + throw new \BadMethodCallException('Unable to revert Site: A test is still being executed.'); } self::$instance = clone self::$original; self::$original = NULL; diff --git a/core/modules/file/tests/file_test/lib/Drupal/file_test/DummyReadOnlyStreamWrapper.php b/core/modules/file/tests/file_test/lib/Drupal/file_test/DummyReadOnlyStreamWrapper.php index d230bc5..8617566 100644 --- a/core/modules/file/tests/file_test/lib/Drupal/file_test/DummyReadOnlyStreamWrapper.php +++ b/core/modules/file/tests/file_test/lib/Drupal/file_test/DummyReadOnlyStreamWrapper.php @@ -7,6 +7,7 @@ namespace Drupal\file_test; +use Drupal\Core\Site\Site; use Drupal\Core\StreamWrapper\LocalReadOnlyStream; /** @@ -16,7 +17,7 @@ */ class DummyReadOnlyStreamWrapper extends LocalReadOnlyStream { function getDirectoryPath() { - return conf_path() . '/files'; + return Site::getPath('files'); } /** diff --git a/core/modules/file/tests/file_test/lib/Drupal/file_test/DummyStreamWrapper.php b/core/modules/file/tests/file_test/lib/Drupal/file_test/DummyStreamWrapper.php index cbea40f..dd919c8 100644 --- a/core/modules/file/tests/file_test/lib/Drupal/file_test/DummyStreamWrapper.php +++ b/core/modules/file/tests/file_test/lib/Drupal/file_test/DummyStreamWrapper.php @@ -7,6 +7,7 @@ namespace Drupal\file_test; +use Drupal\Core\Site\Site; use Drupal\Core\StreamWrapper\LocalStream; /** @@ -16,7 +17,7 @@ */ class DummyStreamWrapper extends LocalStream { function getDirectoryPath() { - return conf_path() . '/files'; + return Site::getPath('files'); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php index 76d0fde..da7dff3 100644 --- a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\DrupalKernel; use Drupal\Core\DrupalKernel; +use Drupal\Core\Site\Site; use Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage; use Drupal\Component\PhpStorage\FileReadOnlyStorage; use Drupal\simpletest\DrupalUnitTestBase; @@ -26,6 +27,9 @@ public static function getInfo() { } function setUp() { + // Initialize the test Site singleton, so that Site::getPath() works. + Site::init(DRUPAL_ROOT); + // DrupalKernel relies on global $config_directories and requires those // directories to exist. Therefore, create the directories, but do not // invoke DrupalUnitTestBase::setUp(), since that would set up further