public function LanguageSwitchingTest::testLanguageBlock in Drupal 10
Same name and namespace in other branches
- 8 core/modules/language/tests/src/Functional/LanguageSwitchingTest.php \Drupal\Tests\language\Functional\LanguageSwitchingTest::testLanguageBlock()
- 9 core/modules/language/tests/src/Functional/LanguageSwitchingTest.php \Drupal\Tests\language\Functional\LanguageSwitchingTest::testLanguageBlock()
Functional tests for the language switcher block.
File
- core/
modules/ language/ tests/ src/ Functional/ LanguageSwitchingTest.php, line 60
Class
- LanguageSwitchingTest
- Functional tests for the language switching feature.
Namespace
Drupal\Tests\language\FunctionalCode
public function testLanguageBlock() {
// Add language.
$edit = [
'predefined_langcode' => 'fr',
];
$this
->drupalGet('admin/config/regional/language/add');
$this
->submitForm($edit, 'Add language');
// Set the native language name.
$this
->saveNativeLanguageName('fr', 'français');
// Enable URL language detection and selection.
$edit = [
'language_interface[enabled][language-url]' => '1',
];
$this
->drupalGet('admin/config/regional/language/detection');
$this
->submitForm($edit, 'Save settings');
// Enable the language switching block.
$block = $this
->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, [
'id' => 'test_language_block',
// Ensure a 2-byte UTF-8 sequence is in the tested output.
'label' => $this
->randomMachineName(8) . '×',
]);
$this
->doTestLanguageBlockAuthenticated($block
->label());
$this
->doTestLanguageBlockAnonymous($block
->label());
}