Commit ad6f3eac authored by alexpott's avatar alexpott

Issue #1770902 by sun, InternetDevels, mbrett5062, tim.plunkett: Theme of...

Issue #1770902 by sun, InternetDevels, mbrett5062, tim.plunkett: Theme of parent site executing test leaks into all tests.
parent 4a06454b
......@@ -55,7 +55,6 @@ abstract class DrupalUnitTestBase extends UnitTestBase {
private $moduleFiles;
private $themeFiles;
private $themeData;
/**
* The configuration directories for this test run.
......@@ -96,7 +95,6 @@ protected function beforePrepareEnvironment() {
if (!isset($this->moduleFiles)) {
$this->moduleFiles = \Drupal::state()->get('system.module.files') ?: array();
$this->themeFiles = \Drupal::state()->get('system.theme.files') ?: array();
$this->themeData = \Drupal::state()->get('system.theme.data') ?: array();
}
}
......@@ -139,7 +137,6 @@ protected function setUp() {
\Drupal::state()->set('system.module.files', $this->moduleFiles);
\Drupal::state()->set('system.theme.files', $this->themeFiles);
\Drupal::state()->set('system.theme.data', $this->themeData);
// Bootstrap the kernel.
// No need to dump it; this test runs in-memory.
......
......@@ -1017,10 +1017,6 @@ private function prepareEnvironment() {
$this->originalContainer = clone \Drupal::getContainer();
$this->originalLanguage = $language_interface;
$this->originalConfigDirectories = $GLOBALS['config_directories'];
if (isset($GLOBALS['theme_key'])) {
$this->originalThemeKey = $GLOBALS['theme_key'];
}
$this->originalTheme = isset($GLOBALS['theme']) ? $GLOBALS['theme'] : NULL;
// Save further contextual information.
// Use the original files directory to avoid nesting it within an existing
......@@ -1099,6 +1095,10 @@ private function prepareEnvironment() {
unset($GLOBALS['conf']);
unset($GLOBALS['theme_key']);
unset($GLOBALS['theme']);
unset($GLOBALS['theme_info']);
unset($GLOBALS['base_theme_info']);
unset($GLOBALS['theme_engine']);
unset($GLOBALS['theme_path']);
// Log fatal errors.
ini_set('log_errors', 1);
......@@ -1220,17 +1220,19 @@ private function restoreEnvironment() {
$connection_info = Database::getConnectionInfo('default');
$databases['default']['default'] = $connection_info['default'];
// Restore original globals.
if (isset($this->originalThemeKey)) {
$GLOBALS['theme_key'] = $this->originalThemeKey;
}
$GLOBALS['theme'] = $this->originalTheme;
// Reset all static variables.
// All destructors of statically cached objects have been invoked above;
// this second reset is guaranteed to reset everything to nothing.
drupal_static_reset();
// Reset global theme variables.
unset($GLOBALS['theme_key']);
unset($GLOBALS['theme']);
unset($GLOBALS['theme_info']);
unset($GLOBALS['base_theme_info']);
unset($GLOBALS['theme_engine']);
unset($GLOBALS['theme_path']);
// Restore original in-memory configuration.
$GLOBALS['config'] = $this->originalConfig;
$GLOBALS['conf'] = $this->originalConf;
......
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