class LanguageConfigFactoryOverrideTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php \Drupal\Tests\language\Kernel\LanguageConfigFactoryOverrideTest
- 9 core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php \Drupal\Tests\language\Kernel\LanguageConfigFactoryOverrideTest
Tests \Drupal\language\Config\LanguageConfigFactoryOverride.
@group language
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\Tests\language\Kernel\LanguageConfigFactoryOverrideTest
Expanded class hierarchy of LanguageConfigFactoryOverrideTest
File
- core/
modules/ language/ tests/ src/ Kernel/ LanguageConfigFactoryOverrideTest.php, line 13
Namespace
Drupal\Tests\language\KernelView source
class LanguageConfigFactoryOverrideTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'system',
'language',
];
/**
* Tests language.config_factory_override service has the default language.
*/
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();
$this->container
->get('kernel')
->rebuildContainer();
$config_factory_override = \Drupal::service('language.config_factory_override');
$this
->assertEquals('de', $config_factory_override
->getLanguage()
->getId());
}
}