diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index 9629ca2..80cc52c 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -82,6 +82,10 @@ function _drupal_maintenance_theme() { $theme = $custom_theme; // Find all our ancestor themes and put them in an array. + // @todo This is just a workaround. Find a better way how to handle themes + // on maintenance pages, see https://www.drupal.org/node/2322619. + // This code is basically a duplicate of + // \Drupal\Core\Theme\ThemeInitialization::getActiveThemeByName. $base_themes = []; $ancestor = $theme; while ($ancestor && isset($themes[$ancestor]->base_theme)) { @@ -92,8 +96,6 @@ function _drupal_maintenance_theme() { $theme_handler->addTheme($themes[$ancestor]); } } - // @todo This is just a workaround. Find a better way how to handle themes - // on maintenance pages, see https://www.drupal.org/node/2322619. \Drupal::theme()->setActiveTheme($theme_init->getActiveTheme($themes[$custom_theme], $base_themes)); // Prime the theme registry. Drupal::service('theme.registry'); diff --git a/core/modules/system/src/Tests/Installer/InstallerThemeTest.php b/core/modules/system/src/Tests/Installer/InstallerThemeTest.php deleted file mode 100644 index 04ebab9..0000000 --- a/core/modules/system/src/Tests/Installer/InstallerThemeTest.php +++ /dev/null @@ -1,45 +0,0 @@ -settingsSet('maintenance_theme', 'seven'); - // Get the maintenance theme loaded. - drupal_maintenance_theme(); - // Do we have an active theme? - $this->assertTrue(\Drupal::theme()->hasActiveTheme()); - - $active_theme = \Drupal::theme()->getActiveTheme(); - $this->assertEqual($active_theme->getName(), 'seven', 'Active maintenance theme is Seven'); - $base_themes = $active_theme->getBaseThemes(); - $base_theme_names = array_keys($base_themes); - // Ensure count and order are correct. - $this->assertTrue(count($base_themes) === 2); - $this->assertEqual($base_theme_names[0], 'classy', 'Classy is the base theme of Seven'); - $this->assertEqual($base_theme_names[1], 'stable', 'Stable is the parent of Classy'); - // Ensure Classy has the correct base themes and amount of base themes. - $classy_base_themes = $base_themes['classy']->getBaseThemes(); - $this->assertTrue(count($classy_base_themes) === 1); - $this->assertTrue(isset($classy_base_themes['stable'])); - } - -} diff --git a/core/modules/system/src/Tests/Installer/StandardInstallerTest.php b/core/modules/system/src/Tests/Installer/StandardInstallerTest.php index 52bd25a..dfe920b 100644 --- a/core/modules/system/src/Tests/Installer/StandardInstallerTest.php +++ b/core/modules/system/src/Tests/Installer/StandardInstallerTest.php @@ -44,7 +44,9 @@ protected function setUpSite() { * {@inheritdoc} */ protected function curlExec($curl_options, $redirect = FALSE) { - // Ensure that we see the classy progress CSS on the page. + // Ensure that we see the classy progress CSS on the batch page. + // Batch processing happens as part of HTTP redirects, so we can access the + // HTML of the batch page. if (strpos($curl_options[CURLOPT_URL], '&id=1&op=do_nojs') !== FALSE) { $this->assertRaw('themes/classy/css/components/progress.css'); } diff --git a/core/tests/Drupal/KernelTests/Core/Theme/MaintenanceThemeTest.php b/core/tests/Drupal/KernelTests/Core/Theme/MaintenanceThemeTest.php new file mode 100644 index 0000000..06ed04b --- /dev/null +++ b/core/tests/Drupal/KernelTests/Core/Theme/MaintenanceThemeTest.php @@ -0,0 +1,43 @@ +setSetting('maintenance_theme', 'seven'); + // Get the maintenance theme loaded. + drupal_maintenance_theme(); + + // Do we have an active theme? + $this->assertTrue(\Drupal::theme()->hasActiveTheme()); + + $active_theme = \Drupal::theme()->getActiveTheme(); + $this->assertEquals('seven', $active_theme->getName()); + + $base_themes = $active_theme->getBaseThemes(); + $base_theme_names = array_keys($base_themes); + $this->assertSame(['classy', 'stable'], $base_theme_names); + + // Ensure Classy has the correct base themes and amount of base themes. + $classy_base_themes = $base_themes['classy']->getBaseThemes(); + $classy_base_theme_names = array_keys($classy_base_themes); + $this->assertSame(['stable'], $classy_base_theme_names); + } + +}