diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index b7848de..1314052 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -128,6 +128,12 @@ protected function setUp() { $modules = array_reverse($modules); $modules = call_user_func_array('array_merge_recursive', $modules); $this->enableModules($modules, FALSE); + + // Re-initialize the theme to ensure that tests do not see an inconsistent + // behavior when calling functions that would initialize the theme if it has + // not been initialized yet. + drupal_theme_initialize(); + // In order to use theme functions default theme config needs to exist. \Drupal::config('system.theme')->set('default', 'stark'); } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 265012e..2ee1d39 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -830,6 +830,11 @@ protected function setUp() { $this->rebuildContainer(); } + // Re-initialize the theme to ensure that tests do not see an inconsistent + // behavior when calling functions that would initialize the theme if it has + // not been initialized yet. + drupal_theme_initialize(); + // Reset/rebuild all data structures after enabling the modules. $this->resetAll();