LanguageSelectorTranslatableTest.php in Drupal 10
File
core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php
View source
<?php
namespace Drupal\Tests\language\Functional;
use Drupal\Tests\BrowserTestBase;
class LanguageSelectorTranslatableTest extends BrowserTestBase {
protected static $modules = [
'language',
'content_translation',
'node',
'comment',
'field_ui',
'entity_test',
'locale',
];
protected $defaultTheme = 'stark';
public $administrator;
protected function setUp() : void {
parent::setUp();
$this->administrator = $this
->drupalCreateUser($this
->getAdministratorPermissions(), 'administrator');
$this
->drupalLogin($this->administrator);
}
protected function getAdministratorPermissions() {
return array_filter([
'translate interface',
'administer content translation',
'create content translations',
'update content translations',
'delete content translations',
'administer languages',
]);
}
public function testLanguageStringSelector() {
$edit = [
'predefined_langcode' => 'es',
];
$this
->drupalGet('admin/config/regional/language/add');
$this
->submitForm($edit, 'Add language');
$name_translation = 'Inglés';
\Drupal::languageManager()
->getLanguageConfigOverride('es', 'language.entity.en')
->set('label', $name_translation)
->save();
$path = 'es/admin/config/regional/content-language';
$this
->drupalGet($path);
$option = $this
->assertSession()
->optionExists('edit-settings-user-user-settings-language-langcode', 'en');
$this
->assertSame($name_translation, $option
->getText());
}
}