protected function RouteCachingNonPathLanguageNegotiationTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalTests/Routing/RouteCachingNonPathLanguageNegotiationTest.php \Drupal\FunctionalTests\Routing\RouteCachingNonPathLanguageNegotiationTest::setUp()
- 9 core/tests/Drupal/FunctionalTests/Routing/RouteCachingNonPathLanguageNegotiationTest.php \Drupal\FunctionalTests\Routing\RouteCachingNonPathLanguageNegotiationTest::setUp()
Overrides BrowserTestBase::setUp
File
- core/
tests/ Drupal/ FunctionalTests/ Routing/ RouteCachingNonPathLanguageNegotiationTest.php, line 38
Class
- RouteCachingNonPathLanguageNegotiationTest
- Tests the route cache when the language is not in the path.
Namespace
Drupal\FunctionalTests\RoutingCode
protected function setUp() : void {
parent::setUp();
// Create and log in user.
$this->adminUser = $this
->drupalCreateUser([
'administer blocks',
'administer languages',
'access administration pages',
]);
$this
->drupalLogin($this->adminUser);
// Add language.
ConfigurableLanguage::createFromLangcode('fr')
->save();
// Enable session language detection and selection.
$edit = [
'language_interface[enabled][language-url]' => FALSE,
'language_interface[enabled][language-session]' => TRUE,
];
$this
->drupalGet('admin/config/regional/language/detection');
$this
->submitForm($edit, 'Save settings');
// A more common scenario is domain-based negotiation but that can not be
// tested. Session negotiation by default is not considered by the URL
// language type that is used to resolve the alias. Explicitly enable
// that to be able to test this scenario.
// @todo Improve in https://www.drupal.org/project/drupal/issues/1125428.
$this
->config('language.types')
->set('negotiation.language_url.enabled', [
'language-session' => 0,
])
->save();
// Enable the language switching block.
$this
->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, [
'id' => 'test_language_block',
]);
}