3 namespace Drupal\views_ui\Tests;
5 use Drupal\language\Entity\ConfigurableLanguage;
6 use Drupal\simpletest\WebTestBase;
9 * Tests that translated strings in views UI don't override original strings.
13 class TranslatedViewTest extends WebTestBase {
20 public static $modules = [
26 * Languages to enable.
30 protected $langcodes = [
35 * Administrator user for tests.
37 * @var \Drupal\user\UserInterface
41 protected function setUp() {
45 'administer site configuration',
47 'translate configuration',
48 'translate interface',
51 // Create and log in user.
52 $this->adminUser = $this->drupalCreateUser($permissions);
53 $this->drupalLogin($this->adminUser);
56 foreach ($this->langcodes as $langcode) {
57 ConfigurableLanguage::createFromLangcode($langcode)->save();
60 $this->rebuildContainer();
63 public function testTranslatedStrings() {
64 $translation_url = 'admin/structure/views/view/files/translate/fr/add';
65 $edit_url = 'admin/structure/views/view/files';
67 // Check origial string.
68 $this->drupalGet($edit_url);
69 $this->assertTitle('Files (File) | Drupal');
71 // Translate the label of the view.
72 $this->drupalGet($translation_url);
74 'translation[config_names][views.view.files][label]' => 'Fichiers',
76 $this->drupalPostForm(NULL, $edit, t('Save translation'));
78 // Check if the label is translated.
79 $this->drupalGet($edit_url, ['language' => \Drupal::languageManager()->getLanguage('fr')]);
80 $this->assertTitle('Files (File) | Drupal');
81 $this->assertNoText('Fichiers');