class ConfigMapperTest

Same name and namespace in other branches
  1. 11.x core/modules/config_translation/tests/src/Kernel/ConfigMapperTest.php \Drupal\Tests\config_translation\Kernel\ConfigMapperTest
  2. 10 core/modules/config_translation/tests/src/Kernel/ConfigMapperTest.php \Drupal\Tests\config_translation\Kernel\ConfigMapperTest
  3. 8.9.x core/modules/config_translation/tests/src/Kernel/ConfigMapperTest.php \Drupal\Tests\config_translation\Kernel\ConfigMapperTest

Tests config mapper.

@group config_translation

Hierarchy

Expanded class hierarchy of ConfigMapperTest

File

core/modules/config_translation/tests/src/Kernel/ConfigMapperTest.php, line 14

Namespace

Drupal\Tests\config_translation\Kernel
View source
class ConfigMapperTest extends KernelTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected 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);
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.