You are here

protected function ConfigNamesMapperTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php \Drupal\Tests\config_translation\Unit\ConfigNamesMapperTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php, line 98
Contains \Drupal\Tests\config_translation\Unit\ConfigNamesMapperTest.

Class

ConfigNamesMapperTest
Tests the functionality provided by the configuration names mapper.

Namespace

Drupal\Tests\config_translation\Unit

Code

protected function setUp() : void {
  $this->routeProvider = $this
    ->createMock('Drupal\\Core\\Routing\\RouteProviderInterface');
  $this->pluginDefinition = [
    'class' => '\\Drupal\\config_translation\\ConfigNamesMapper',
    'base_route_name' => 'system.site_information_settings',
    'title' => 'System information',
    'names' => [
      'system.site',
    ],
    'weight' => 42,
  ];
  $this->typedConfigManager = $this
    ->createMock('Drupal\\Core\\Config\\TypedConfigManagerInterface');
  $this->localeConfigManager = $this
    ->getMockBuilder('Drupal\\locale\\LocaleConfigManager')
    ->disableOriginalConstructor()
    ->getMock();
  $this->configMapperManager = $this
    ->createMock('Drupal\\config_translation\\ConfigMapperManagerInterface');
  $this->urlGenerator = $this
    ->createMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
  $container = new ContainerBuilder();
  $container
    ->set('url_generator', $this->urlGenerator);
  \Drupal::setContainer($container);
  $this->baseRoute = new Route('/admin/config/system/site-information');
  $this->routeProvider
    ->expects($this
    ->any())
    ->method('getRouteByName')
    ->with('system.site_information_settings')
    ->will($this
    ->returnValue($this->baseRoute));
  $this->languageManager = $this
    ->createMock('Drupal\\Core\\Language\\LanguageManagerInterface');
  $this->eventDispatcher = $this
    ->createMock('Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface');
  $this->configNamesMapper = new TestConfigNamesMapper('system.site_information_settings', $this->pluginDefinition, $this
    ->getConfigFactoryStub(), $this->typedConfigManager, $this->localeConfigManager, $this->configMapperManager, $this->routeProvider, $this
    ->getStringTranslationStub(), $this->languageManager, $this->eventDispatcher);
}