diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php index 084be15..cf02e09 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php @@ -152,7 +152,7 @@ function testImport() { $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array()); $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', array()); $expected = array('ban', 'action', 'text', 'options'); - $this->assertIdentical($expected, $installed, 'Ban, Action, Text and Options modules installed in the correct order.'); + $this->assertIdentical($expected, $installed); $this->assertTrue(empty($uninstalled), 'No modules uninstalled during import'); // Verify that the action.settings configuration object was only written @@ -206,11 +206,11 @@ function testImport() { $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array()); $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', array()); $expected = array('options', 'text', 'ban', 'action'); - $this->assertIdentical($expected, $uninstalled, 'Options, Text, Action and Ban modules uninstalled in the correct order.'); + $this->assertIdentical($expected, $uninstalled); $this->assertTrue(empty($installed), 'No modules installed during import'); $theme_info = \Drupal::service('theme_handler')->listInfo(); - $this->assertTrue(isset($theme_info['bartik']) && !$theme_info['bartik']->status, 'Bartik theme disabled during import.'); + $this->assertFalse(isset($theme_info['bartik']), 'Bartik theme disabled during import.'); // Verify that the action.settings configuration object was only deleted // once during the import process. diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index 0db169e..00ff081 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -56,6 +56,28 @@ function config_translation_theme() { } /** + * Implements hook_themes_enabled(). + */ +function config_translation_themes_enabled() { + // Themes can provide *.config_translation.yml declarations. + // @todo Make ThemeHandler trigger an event instead and make + // ConfigMapperManager plugin manager subscribe to it. + // @see https://drupal.org/node/2206347 + \Drupal::service('plugin.manager.config_translation.mapper')->clearCachedDefinitions(); +} + +/** + * Implements hook_themes_disabled(). + */ +function config_translation_themes_disabled() { + // Themes can provide *.config_translation.yml declarations. + // @todo Make ThemeHandler trigger an event instead and make + // ConfigMapperManager plugin manager subscribe to it. + // @see https://drupal.org/node/2206347 + \Drupal::service('plugin.manager.config_translation.mapper')->clearCachedDefinitions(); +} + +/** * Implements hook_entity_type_alter(). */ function config_translation_entity_type_alter(array &$entity_types) { diff --git a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php index bdfbe55..e90c5bf 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php @@ -67,6 +67,14 @@ public function __construct(CacheBackendInterface $cache_backend, LanguageManage $this->typedConfigManager = $typed_config_manager; // Look at all themes and modules. + // @todo If the list of enabled modules and themes is changed, new + // definitions are not picked up immediately and obsolete definitions are + // not removed, because the list of search directories is only compiled + // once in this constructor. The current code only works due to + // coincidence: The request that enables e.g. a new theme does not + // instantiate this plugin manager at the beginning of the request; when + // routes are being rebuilt at the end of the request, this service only + // happens to get instantiated with the updated list of enabled themes. $directories = array(); foreach ($module_handler->getModuleList() as $name => $module) { $directories[$name] = $module->getPath(); diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiTest.php index 405aaf5..4376a04 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiTest.php @@ -656,25 +656,6 @@ public function testAlterInfo() { } /** - * Tests that theme provided *.config_translation.yml files are found. - */ - public function testThemeDiscovery() { - // Enable the test theme and rebuild routes. - $theme = 'config_translation_test_theme'; - theme_enable(array($theme)); - // Enabling a theme will cause the kernel terminate event to rebuild the - // router. Simulate that here. - \Drupal::service('router.builder')->rebuildIfNeeded(); - - $this->drupalLogin($this->admin_user); - - $translation_base_url = 'admin/config/development/performance/translate'; - $this->drupalGet($translation_base_url); - $this->assertResponse(200); - $this->assertLinkByHref("$translation_base_url/fr/add"); - } - - /** * Gets translation from locale storage. * * @param $config_name diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiThemeTest.php b/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiThemeTest.php new file mode 100644 index 0000000..b51cee3 --- /dev/null +++ b/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiThemeTest.php @@ -0,0 +1,88 @@ + 'Theme Configuration Translation', + 'description' => 'Verifies theme configuration translation settings.', + 'group' => 'Configuration Translation', + ); + } + + public function setUp() { + parent::setUp(); + + $admin_permissions = array( + 'administer themes', + 'administer languages', + 'administer site configuration', + 'translate configuration', + ); + // Create and login user. + $this->admin_user = $this->drupalCreateUser($admin_permissions); + + // Add languages. + foreach ($this->langcodes as $langcode) { + $language = new Language(array('id' => $langcode)); + language_save($language); + } + } + + /** + * Tests that theme provided *.config_translation.yml files are found. + */ + public function testThemeDiscovery() { + // Enable the test theme and rebuild routes. + $theme = 'config_translation_test_theme'; + + $this->drupalLogin($this->admin_user); + + $this->drupalGet('admin/appearance'); + $elements = $this->xpath('//a[normalize-space()=:label and contains(@href, :theme)]', array( + ':label' => 'Enable and set as default', + ':theme' => $theme, + )); + $this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], array('external' => TRUE)); + + $translation_base_url = 'admin/config/development/performance/translate'; + $this->drupalGet($translation_base_url); + $this->assertResponse(200); + $this->assertLinkByHref("$translation_base_url/fr/add"); + } + +} diff --git a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module index c71166f..d38be97 100644 --- a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module +++ b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module @@ -5,6 +5,18 @@ * Configuration Translation Test module. */ +use Drupal\Core\Extension\Extension; + +/** + * Implements hook_system_info_alter(). + */ +function config_translation_test_system_info_alter(array &$info, Extension $file, $type) { + // @see \Drupal\config_translation\Tests\ConfigTranslationUiThemeTest + if ($file->getType() == 'theme' && $file->getName() == 'config_translation_test_theme') { + $info['hidden'] = FALSE; + } +} + /** * Implements hook_entity_type_alter(). */ diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php index a464ad2..7c4eeda 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php @@ -274,6 +274,9 @@ public function testRebuildThemeData() { $info_parser = new InfoParser(); return $info_parser->parse($file); })); + $this->moduleHandler->expects($this->once()) + ->method('buildModuleDependencies') + ->will($this->returnArgument(0)); $this->moduleHandler->expects($this->once()) ->method('alter'); @@ -336,6 +339,9 @@ public function testRebuildThemeDataWithThemeParents() { $info_parser = new InfoParser(); return $info_parser->parse($file); })); + $this->moduleHandler->expects($this->once()) + ->method('buildModuleDependencies') + ->will($this->returnArgument(0)); $theme_data = $this->themeHandler->rebuildThemeData(); $this->assertCount(2, $theme_data);