Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / config_translation / tests / src / Kernel / ConfigMapperTest.php
diff --git a/web/core/modules/config_translation/tests/src/Kernel/ConfigMapperTest.php b/web/core/modules/config_translation/tests/src/Kernel/ConfigMapperTest.php
new file mode 100644 (file)
index 0000000..773246c
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+namespace Drupal\Tests\config_translation\Kernel;
+
+use Drupal\Core\Routing\RouteMatch;
+use Drupal\KernelTests\KernelTestBase;
+use Symfony\Component\Routing\Route;
+
+/**
+ * Tests config mapper.
+ *
+ * @group config_translation
+ */
+class ConfigMapperTest extends KernelTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = [
+    'config_translation',
+    'config_translation_test',
+    'language',
+    'locale',
+    'system',
+  ];
+
+  /**
+   * Tests adding config names to mapper.
+   */
+  public function testAddingConfigNames() {
+    // Get a config names mapper.
+    $mappers = \Drupal::service('plugin.manager.config_translation.mapper')->getMappers();
+    $mapper = $mappers['system.site_information_settings'];
+
+    // Test that it doesn't contain a config name from config_translation_test.
+    $config_names = $mapper->getConfigNames();
+    $this->assertNotContains('config_translation_test.content', $config_names);
+
+    // Call populateFromRouteMatch() to dispatch the "config mapper populate"
+    // event.
+    $mapper->populateFromRouteMatch(new RouteMatch('test', new Route('/')));
+
+    // Test that it contains the new config name from config_translation_test.
+    $config_names = $mapper->getConfigNames();
+    $this->assertContains('config_translation_test.content', $config_names);
+  }
+
+}