View source
<?php
namespace Drupal\language\Tests;
use Drupal\simpletest\WebTestBase;
class LanguageSelectorTranslatableTest extends WebTestBase {
public static $modules = array(
'language',
'content_translation',
'node',
'comment',
'field_ui',
'entity_test',
'locale',
);
public $administrator;
protected function setUp() {
parent::setUp();
$this->administrator = $this
->drupalCreateUser($this
->getAdministratorPermissions(), 'administrator');
$this
->drupalLogin($this->administrator);
}
protected function getAdministratorPermissions() {
return array_filter(array(
'translate interface',
'administer content translation',
'create content translations',
'update content translations',
'delete content translations',
'administer languages',
));
}
public function testLanguageStringSelector() {
$edit = array(
'predefined_langcode' => 'es',
);
$this
->drupalPostForm('admin/config/regional/language/add', $edit, t('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);
$elements = $this
->xpath('//select[@id=:id]//option[@value=:option]', array(
':id' => 'edit-settings-user-user-settings-language-langcode',
':option' => 'en',
));
$this
->assertEqual((string) $elements[0], $name_translation, 'Checking the option string English is translated to Spanish.');
}
}