function LanguageBrowserDetectionAcceptLanguageTest::setUp
Same name in other branches
- 9 core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php \Drupal\Tests\language\Functional\LanguageBrowserDetectionAcceptLanguageTest::setUp()
- 8.9.x core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php \Drupal\Tests\language\Functional\LanguageBrowserDetectionAcceptLanguageTest::setUp()
- 10 core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php \Drupal\Tests\language\Functional\LanguageBrowserDetectionAcceptLanguageTest::setUp()
Overrides BrowserTestBase::setUp
File
-
core/
modules/ language/ tests/ src/ Functional/ LanguageBrowserDetectionAcceptLanguageTest.php, line 35
Class
- LanguageBrowserDetectionAcceptLanguageTest
- Tests browser language detection with different accept-language headers.
Namespace
Drupal\Tests\language\FunctionalCode
protected function setUp() : void {
parent::setUp();
// User to manage languages.
$admin = $this->drupalCreateUser([], NULL, TRUE);
$this->drupalLogin($admin);
// Create FR.
ConfigurableLanguage::createFromLangcode('fr')->save();
// Set language detection to URL and browser detection.
$this->drupalGet('/admin/config/regional/language/detection');
$this->submitForm([
'language_interface[enabled][language-url]' => TRUE,
'language_interface[enabled][language-browser]' => TRUE,
'language_interface[enabled][language-selected]' => TRUE,
], 'Save settings');
// Set prefixes to en and fr.
$this->drupalGet('/admin/config/regional/language/detection/url');
$this->submitForm([
'prefix[en]' => 'en',
'prefix[fr]' => 'fr',
], 'Save configuration');
// Add language codes to browser detection.
$this->drupalGet('/admin/config/regional/language/detection/browser');
$this->submitForm([
'new_mapping[browser_langcode]' => 'fr',
'new_mapping[drupal_langcode]' => 'fr',
], 'Save configuration');
$this->drupalGet('/admin/config/regional/language/detection/browser');
$this->submitForm([
'new_mapping[browser_langcode]' => 'en',
'new_mapping[drupal_langcode]' => 'en',
], 'Save configuration');
$this->drupalGet('/admin/config/regional/language/detection/selected');
$this->submitForm([
'edit-selected-langcode' => 'en',
], 'Save configuration');
$this->drupalLogout();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.