function LanguageConfigFactoryOverrideTest::testLanguageConfigFactoryOverride

Same name in other branches
  1. 9 core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php \Drupal\Tests\language\Kernel\LanguageConfigFactoryOverrideTest::testLanguageConfigFactoryOverride()
  2. 10 core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php \Drupal\Tests\language\Kernel\LanguageConfigFactoryOverrideTest::testLanguageConfigFactoryOverride()
  3. 11.x core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php \Drupal\Tests\language\Kernel\LanguageConfigFactoryOverrideTest::testLanguageConfigFactoryOverride()

Tests language.config_factory_override service has the default language.

File

core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php, line 25

Class

LanguageConfigFactoryOverrideTest
Tests \Drupal\language\Config\LanguageConfigFactoryOverride.

Namespace

Drupal\Tests\language\Kernel

Code

public function testLanguageConfigFactoryOverride() {
    $this->installConfig('system');
    $this->installConfig('language');
    
    /** @var \Drupal\language\Config\LanguageConfigFactoryOverride $config_factory_override */
    $config_factory_override = \Drupal::service('language.config_factory_override');
    $this->assertEquals('en', $config_factory_override->getLanguage()
        ->getId());
    ConfigurableLanguage::createFromLangcode('de')->save();
    // Invalidate the container.
    $this->config('system.site')
        ->set('default_langcode', 'de')
        ->save();
    drupal_flush_all_caches();
    $config_factory_override = \Drupal::service('language.config_factory_override');
    $this->assertEquals('de', $config_factory_override->getLanguage()
        ->getId());
}

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