summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGábor Hojtsy2018-11-01 21:22:48 (GMT)
committerGábor Hojtsy2018-11-01 21:22:48 (GMT)
commit09021c59266925f534df587b59f7c6b5eaf2a883 (patch)
treec2e2bdea3ad45a4d07f1ec0dee01d576ee34312f
parent786a4e2041c0245bce8e62205cc443d4adb59d8a (diff)
Issue #2970847 by quietone, phenaproxima: i18n Variable to config: system site settings [d7]
-rw-r--r--core/modules/config_translation/migrations/d7_system_site_translation.yml27
-rw-r--r--core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateSystemSiteTranslationTest.php54
-rw-r--r--core/modules/migrate_drupal/tests/fixtures/drupal7.php70
3 files changed, 151 insertions, 0 deletions
diff --git a/core/modules/config_translation/migrations/d7_system_site_translation.yml b/core/modules/config_translation/migrations/d7_system_site_translation.yml
new file mode 100644
index 0000000..9aac86d
--- /dev/null
+++ b/core/modules/config_translation/migrations/d7_system_site_translation.yml
@@ -0,0 +1,27 @@
+id: d7_system_site_translation
+label: Site configuration translation
+migration_tags:
+ - Drupal 7
+ - Configuration
+ - Multilingual
+source:
+ plugin: d7_variable_translation
+ variables:
+ - site_name
+ - site_mail
+ - site_slogan
+ - site_frontpage
+ - site_403
+ - site_404
+process:
+ langcode: language
+ name: site_name
+ mail: site_mail
+ slogan: site_slogan
+ 'page/front': site_frontpage
+ 'page/403': site_403
+ 'page/404': site_404
+destination:
+ plugin: config
+ config_name: system.site
+ translations: true
diff --git a/core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateSystemSiteTranslationTest.php b/core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateSystemSiteTranslationTest.php
new file mode 100644
index 0000000..e25a0f8
--- /dev/null
+++ b/core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateSystemSiteTranslationTest.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace Drupal\Tests\config_translation\Kernel\Migrate\d7;
+
+use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
+
+/**
+ * Migrate multilingual site variables.
+ *
+ * @group migrate_drupal_7
+ */
+class MigrateSystemSiteTranslationTest extends MigrateDrupal7TestBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = [
+ 'language',
+ 'config_translation',
+ // Required for translation migrations.
+ 'migrate_drupal_multilingual',
+ ];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $this->executeMigration('d7_system_site_translation');
+ }
+
+ /**
+ * Tests migration of system (site) variables to system.site.yml.
+ */
+ public function testSystemSite() {
+ $language_manager = \Drupal::service('language_manager');
+ $config_translation = $language_manager->getLanguageConfigOverride('fr', 'system.site');
+ $this->assertSame('The Site Name', $config_translation->get('name'));
+ $this->assertSame('fr - The Slogan', $config_translation->get('slogan'));
+ $this->assertSame('node', $config_translation->get('page.403'));
+ $this->assertSame('node', $config_translation->get('page.404'));
+ $this->assertSame('node', $config_translation->get('page.front'));
+ $this->assertSame(NULL, $config_translation->get('admin_compact_mode'));
+
+ $config_translation = $language_manager->getLanguageConfigOverride('is', 'system.site');
+ $this->assertSame('is - The Site Name', $config_translation->get('name'));
+ $this->assertSame('is - The Slogan', $config_translation->get('slogan'));
+ $this->assertSame('node/1', $config_translation->get('page.403'));
+ $this->assertSame('node/6', $config_translation->get('page.404'));
+ $this->assertSame('node/4', $config_translation->get('page.front'));
+ $this->assertNULL($config_translation->get('admin_compact_mode'));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
index 9e3e204..bf91e17 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
@@ -51469,6 +51469,76 @@ $connection->insert('variable_store')
'value' => 'is - This is a custom maintenance mode message.',
'serialized' => '0',
))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'site_403',
+ 'value' => 'node/1',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'site_404',
+ 'value' => 'node/6',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'site_frontpage',
+ 'value' => 'node/4',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'site_name',
+ 'value' => 'is - The Site Name',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'site_slogan',
+ 'value' => 'is - The Slogan',
+ 'serialized' => '0',
+))
+ ->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'fr',
+ 'name' => 'site_403',
+ 'value' => 'node',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'fr',
+ 'name' => 'site_404',
+ 'value' => 'node',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'fr',
+ 'name' => 'site_frontpage',
+ 'value' => 'node',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'fr',
+ 'name' => 'site_name',
+ 'value' => 'The Site Name',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'fr',
+ 'name' => 'site_slogan',
+ 'value' => 'fr - The Slogan',
+ 'serialized' => '0',
+))
->execute();
$connection->schema()->createTable('watchdog', array(