diff --git a/core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php b/core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php index 03b458e..d21623a 100644 --- a/core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php +++ b/core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php @@ -7,8 +7,8 @@ namespace Drupal\language\Tests; +use Drupal; use Drupal\simpletest\WebTestBase; -use Drupal\Core\Language\Language; /** * Tests the Content translation settings using the standard profile. @@ -16,11 +16,7 @@ * @group language */ class LanguageSelectorTranslatableTest extends WebTestBase { - /** - * Modules to enable. - * - * @var array - */ + public static $modules = array( 'language', 'content_translation', @@ -41,7 +37,7 @@ protected function setUp() { parent::setUp(); // Create user and set permissions. - $this->administrator = $this->drupalCreateUser($this->getAdministratorPermissions(),'administrator'); + $this->administrator = $this->drupalCreateUser($this->getAdministratorPermissions(), 'administrator'); $this->drupalLogin($this->administrator); } @@ -49,43 +45,37 @@ protected function setUp() { * Returns an array of permissions needed for the translator. */ protected function getAdministratorPermissions() { - return array_filter(array('translate interface', 'administer content translation', 'create content translations', 'update content translations', 'delete content translations', 'administer languages')); + return array_filter( + array('translate interface', + 'administer content translation', + 'create content translations', + 'update content translations', + 'delete content translations', + 'administer languages' + ) + ); } /** - * + * Test Content Translation language selectors are correctly translate. */ - function testLanguageStringSelector() { - + public function testLanguageStringSelector() { // Add another language. - $edit = array('predefined_langcode' => 'es',); + $edit = array('predefined_langcode' => 'es'); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); - // Translate the string English in Spanish (Inglés). - $name = 'English'; + // Translate the string English in Spanish (Inglés). Override config entity. $name_translation = 'Inglés'; - $search = array( - 'string' => $name, - 'langcode' => 'es', - 'translation' => 'untranslated', - ); - $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); - $this->assertText($name, 'Search found the string as untranslated.'); + $override = Drupal::languageManager()->getLanguageConfigOverride('es', 'language.entity.en')->set('label', $name_translation)->save(); - // Assume this is the only result, given the random name. - $textarea = current($this->xpath('//textarea')); - $lid = (string) $textarea[0]['name']; - $edit = array( - $lid => $name_translation, - ); - $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); - $this->assertText(t('The strings have been saved.'), 'The strings have been saved.'); + // Check label is set correctly. + $this->assertEqual($override->get('label'), $name_translation, 'Language label for English is translate into Spanish.'); // Check content translation overview selector. $path = 'es/admin/config/regional/content-language'; $this->drupalGet($path); - // Get en language from selector + // Get en language from selector. $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => 'edit-settings-node-node-settings-language-langcode', ':option' => 'en')); // Check the language text is translated.