diff --git a/core/modules/system/src/Tests/Extension/ThemeInstallerTest.php b/core/modules/system/src/Tests/Extension/ThemeInstallerTest.php index 6a03119..941ae9b 100644 --- a/core/modules/system/src/Tests/Extension/ThemeInstallerTest.php +++ b/core/modules/system/src/Tests/Extension/ThemeInstallerTest.php @@ -63,7 +63,7 @@ function testInstall() { $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); - $this->themeHandler()->install(array($name)); + $this->themeInstaller()->install(array($name)); $this->assertIdentical($this->extensionConfig()->get("theme.$name"), 0); @@ -89,13 +89,13 @@ function testInstallSubTheme() { $themes = $this->themeHandler()->listInfo(); $this->assertFalse(array_keys($themes)); - $this->themeHandler()->install(array($name)); + $this->themeInstaller()->install(array($name)); $themes = $this->themeHandler()->listInfo(); $this->assertTrue(isset($themes[$name])); $this->assertTrue(isset($themes[$base_name])); - $this->themeHandler()->uninstall(array($name)); + $this->themeInstaller()->uninstall(array($name)); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); @@ -113,7 +113,7 @@ function testInstallNonExisting() { try { $message = 'ThemeHandler::install() throws InvalidArgumentException upon installing a non-existing theme.'; - $this->themeHandler()->install(array($name)); + $this->themeInstaller()->install(array($name)); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -132,7 +132,7 @@ function testInstallNameTooLong() { try { $message = 'ThemeHandler::install() throws ExtensionNameLengthException upon installing a theme with a too long name.'; - $this->themeHandler()->install(array($name)); + $this->themeInstaller()->install(array($name)); $this->fail($message); } catch (ExtensionNameLengthException $e) { @@ -146,7 +146,7 @@ function testInstallNameTooLong() { function testUninstallDefault() { $name = 'stark'; $other_name = 'bartik'; - $this->themeHandler()->install(array($name, $other_name)); + $this->themeInstaller()->install(array($name, $other_name)); $this->themeHandler()->setDefault($name); $themes = $this->themeHandler()->listInfo(); @@ -173,7 +173,7 @@ function testUninstallDefault() { function testUninstallAdmin() { $name = 'stark'; $other_name = 'bartik'; - $this->themeHandler()->install(array($name, $other_name)); + $this->themeInstaller()->install(array($name, $other_name)); $this->config('system.theme')->set('admin', $name)->save(); $themes = $this->themeHandler()->listInfo(); @@ -201,8 +201,8 @@ function testUninstallSubTheme() { $name = 'test_subtheme'; $base_name = 'test_basetheme'; - $this->themeHandler()->install(array($name)); - $this->themeHandler()->uninstall(array($name)); + $this->themeInstaller()->install(array($name)); + $this->themeInstaller()->uninstall(array($name)); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); @@ -216,11 +216,11 @@ function testUninstallBaseBeforeSubTheme() { $name = 'test_basetheme'; $sub_name = 'test_subtheme'; - $this->themeHandler()->install(array($sub_name)); + $this->themeInstaller()->install(array($sub_name)); try { $message = 'ThemeHandler::install() throws InvalidArgumentException upon uninstalling base theme before sub theme.'; - $this->themeHandler()->uninstall(array($name)); + $this->themeInstaller()->uninstall(array($name)); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -232,7 +232,7 @@ function testUninstallBaseBeforeSubTheme() { $this->assertTrue(isset($themes[$sub_name])); // Verify that uninstalling both at the same time works. - $this->themeHandler()->uninstall(array($name, $sub_name)); + $this->themeInstaller()->uninstall(array($name, $sub_name)); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); @@ -250,7 +250,7 @@ function testUninstallNonExisting() { try { $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon uninstalling a non-existing theme.'; - $this->themeHandler()->uninstall(array($name)); + $this->themeInstaller()->uninstall(array($name)); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -267,10 +267,10 @@ function testUninstallNonExisting() { function testUninstall() { $name = 'test_basetheme'; - $this->themeHandler()->install(array($name)); + $this->themeInstaller()->install(array($name)); $this->assertTrue($this->config("$name.settings")->get()); - $this->themeHandler()->uninstall(array($name)); + $this->themeInstaller()->uninstall(array($name)); $this->assertFalse(array_keys($this->themeHandler()->listInfo())); $this->assertFalse(array_keys(system_list('theme'))); @@ -278,7 +278,7 @@ function testUninstall() { $this->assertFalse($this->config("$name.settings")->get()); // Ensure that the uninstalled theme can be installed again. - $this->themeHandler()->install(array($name)); + $this->themeInstaller()->install(array($name)); $themes = $this->themeHandler()->listInfo(); $this->assertTrue(isset($themes[$name])); $this->assertEqual($themes[$name]->getName(), $name); @@ -294,7 +294,7 @@ function testUninstallNotInstalled() { try { $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon uninstalling a theme that is not installed.'; - $this->themeHandler()->uninstall(array($name)); + $this->themeInstaller()->uninstall(array($name)); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -311,7 +311,7 @@ function testThemeInfoAlter() { $name = 'seven'; $this->container->get('state')->set('module_test.hook_system_info_alter', TRUE); - $this->themeHandler()->install(array($name)); + $this->themeInstaller()->install(array($name)); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name]->info['regions']['test_region'])); @@ -359,21 +359,21 @@ protected function themeHandler() { } /** - * Returns the system.theme config object. + * Returns the theme installer service. * - * @return \Drupal\Core\Config\Config + * @return \Drupal\Core\Extension\ThemeInstallerInterface */ - protected function extensionConfig() { - return $this->config('core.extension'); + protected function themeInstaller() { + return $this->container->get('theme_installer'); } /** - * Returns the active configuration storage. + * Returns the system.theme config object. * - * @return \Drupal\Core\Config\ConfigStorageInterface + * @return \Drupal\Core\Config\Config */ - protected function configStorage() { - return $this->container->get('config.storage'); + protected function extensionConfig() { + return $this->config('core.extension'); } /** diff --git a/core/modules/system/tests/themes/test_basetheme/config/install/core.date_format.fancy.yml b/core/modules/system/tests/themes/test_basetheme/config/install/core.date_format.fancy.yml index 05d5e27..2b962d6 100644 --- a/core/modules/system/tests/themes/test_basetheme/config/install/core.date_format.fancy.yml +++ b/core/modules/system/tests/themes/test_basetheme/config/install/core.date_format.fancy.yml @@ -1,6 +1,6 @@ # Themes are not supposed to provide/install this kind of config normally. # This exists for testing purposes only. -# @see \Drupal\system\Tests\Extension\ThemeHandlerTest +# @see \Drupal\system\Tests\Extension\ThemeInstallerTest id: fancy label: 'Fancy date' status: true diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php index 84d4266..f9eaf02 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Tests\Core\Extension\ThemeHandlerTest. + * Contains \Drupal\Tests\Core\Extension\ThemeInstallerTest. */ namespace Drupal\Tests\Core\Extension; @@ -22,13 +22,6 @@ class ThemeHandlerTest extends UnitTestCase { /** - * The mocked route builder. - * - * @var \Drupal\Core\Routing\RouteBuilderInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $routeBuilder; - - /** * The mocked info parser. * * @var \Drupal\Core\Extension\InfoParserInterface|\PHPUnit_Framework_MockObject_MockObject @@ -57,20 +50,6 @@ class ThemeHandlerTest extends UnitTestCase { protected $moduleHandler; /** - * The mocked config installer. - * - * @var \Drupal\Core\Config\ConfigInstaller|\PHPUnit_Framework_MockObject_MockObject - */ - protected $configInstaller; - - /** - * The mocked config manager. - * - * @var \Drupal\Core\Config\ConfigManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $configManager; - - /** * The extension discovery. * * @var \Drupal\Core\Extension\ExtensionDiscovery|\PHPUnit_Framework_MockObject_MockObject @@ -78,13 +57,6 @@ class ThemeHandlerTest extends UnitTestCase { protected $extensionDiscovery; /** - * The CSS asset collection optimizer service. - * - * @var \Drupal\Core\Asset\AssetCollectionOptimizerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $cssCollectionOptimizer; - - /** * The tested theme handler. * * @var \Drupal\Core\Extension\ThemeHandler|\Drupal\Tests\Core\Extension\TestThemeHandler @@ -109,17 +81,10 @@ protected function setUp() { $this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); $this->state = new State(new KeyValueMemoryFactory()); $this->infoParser = $this->getMock('Drupal\Core\Extension\InfoParserInterface'); - $this->configInstaller = $this->getMock('Drupal\Core\Config\ConfigInstallerInterface'); - $this->configManager = $this->getMock('Drupal\Core\Config\ConfigManagerInterface'); - $this->routeBuilder = $this->getMock('Drupal\Core\Routing\RouteBuilderInterface'); $this->extensionDiscovery = $this->getMockBuilder('Drupal\Core\Extension\ExtensionDiscovery') ->disableOriginalConstructor() ->getMock(); - $this->cssCollectionOptimizer = $this->getMockBuilder('\Drupal\Core\Asset\CssCollectionOptimizer') //\Drupal\Core\Asset\AssetCollectionOptimizerInterface'); - ->disableOriginalConstructor() - ->getMock(); - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->themeHandler = new TestThemeHandler($this->root, $this->configFactory, $this->moduleHandler, $this->state, $this->infoParser, $logger, $this->cssCollectionOptimizer, $this->configInstaller, $this->configManager, $this->routeBuilder, $this->extensionDiscovery); + $this->themeHandler = new TestThemeHandler($this->root, $this->configFactory, $this->moduleHandler, $this->state, $this->infoParser, $this->extensionDiscovery); $cache_tags_invalidator = $this->getMock('Drupal\Core\Cache\CacheTagsInvalidatorInterface'); $this->getContainerWithCacheTagsInvalidator($cache_tags_invalidator);