diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index f53bb0c997d5bc0bdb9cfad0dc7dd4bae860a12e..4059d791cd266f2d09f11a1ae1a2203371c86100 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -167,7 +167,7 @@ public function setDefault($name) { public function install(array $theme_list, $install_dependencies = TRUE) { // We keep the old install() method as BC layer but redirect directly to the // theme installer. - \Drupal::service('theme_installer')->install($theme_list, $install_dependencies); + return \Drupal::service('theme_installer')->install($theme_list, $install_dependencies); } /** diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php index 3c36ae4308d9df46f389b50693440523ac9acd03..84745b7c29772571e90c4edc618f45d89d063651 100644 --- a/core/modules/system/src/Tests/System/ThemeTest.php +++ b/core/modules/system/src/Tests/System/ThemeTest.php @@ -334,4 +334,28 @@ function testUninstallingThemes() { $this->clickLink(t('Uninstall')); $this->assertRaw('The <em class="placeholder">Classy</em> theme has been uninstalled'); } + + /** + * Tests installing a theme and setting it as default. + */ + function testInstallAndSetAsDefault() { + $this->drupalGet('admin/appearance'); + // Bartik is uninstalled in the test profile and has the second "Install and + // set as default" link. + $this->clickLink(t('Install and set as default'), 1); + // Test the confirmation message. + $this->assertText('Bartik is now the default theme.'); + // Make sure Bartik is now set as the default theme in config. + $this->assertEqual($this->config('system.theme')->get('default'), 'bartik'); + + // This checks for a regression. See https://www.drupal.org/node/2498691. + $this->assertNoText('The bartik theme was not found.'); + + $themes = \Drupal::service('theme_handler')->rebuildThemeData(); + $version = $themes['bartik']->info['version']; + + // Confirm Bartik is indicated as the default theme. + $this->assertTextPattern('/Bartik ' . preg_quote($version) . '\s{2,}\(default theme\)/'); + } + }