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
1 <?php
2
3 namespace Drupal\Tests\config_translation\Kernel;
4
5 use Drupal\Core\Routing\RouteMatch;
6 use Drupal\KernelTests\KernelTestBase;
7 use Symfony\Component\Routing\Route;
8
9 /**
10  * Tests config mapper.
11  *
12  * @group config_translation
13  */
14 class ConfigMapperTest extends KernelTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = [
20     'config_translation',
21     'config_translation_test',
22     'language',
23     'locale',
24     'system',
25   ];
26
27   /**
28    * Tests adding config names to mapper.
29    */
30   public function testAddingConfigNames() {
31     // Get a config names mapper.
32     $mappers = \Drupal::service('plugin.manager.config_translation.mapper')->getMappers();
33     $mapper = $mappers['system.site_information_settings'];
34
35     // Test that it doesn't contain a config name from config_translation_test.
36     $config_names = $mapper->getConfigNames();
37     $this->assertNotContains('config_translation_test.content', $config_names);
38
39     // Call populateFromRouteMatch() to dispatch the "config mapper populate"
40     // event.
41     $mapper->populateFromRouteMatch(new RouteMatch('test', new Route('/')));
42
43     // Test that it contains the new config name from config_translation_test.
44     $config_names = $mapper->getConfigNames();
45     $this->assertContains('config_translation_test.content', $config_names);
46   }
47
48 }