Backup of db before drupal security update
[yaffs-website] / web / core / modules / views_ui / tests / src / Functional / TranslatedViewTest.php
1 <?php
2
3 namespace Drupal\Tests\views_ui\Functional;
4
5 use Drupal\language\Entity\ConfigurableLanguage;
6
7 /**
8  * Tests that translated strings in views UI don't override original strings.
9  *
10  * @group views_ui
11  */
12 class TranslatedViewTest extends UITestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = [
20     'config_translation',
21     'views_ui',
22   ];
23
24   /**
25    * Languages to enable.
26    *
27    * @var array
28    */
29   protected $langcodes = [
30     'fr',
31   ];
32
33   /**
34    * Administrator user for tests.
35    *
36    * @var \Drupal\user\UserInterface
37    */
38   protected $adminUser;
39
40   protected function setUp($import_test_views = TRUE) {
41     parent::setUp($import_test_views);
42
43     $permissions = [
44       'administer site configuration',
45       'administer views',
46       'translate configuration',
47       'translate interface',
48     ];
49
50     // Create and log in user.
51     $this->adminUser = $this->drupalCreateUser($permissions);
52     $this->drupalLogin($this->adminUser);
53
54     // Add languages.
55     foreach ($this->langcodes as $langcode) {
56       ConfigurableLanguage::createFromLangcode($langcode)->save();
57     }
58     $this->resetAll();
59     $this->rebuildContainer();
60   }
61
62   public function testTranslatedStrings() {
63     $translation_url = 'admin/structure/views/view/files/translate/fr/add';
64     $edit_url = 'admin/structure/views/view/files';
65
66     // Check origial string.
67     $this->drupalGet($edit_url);
68     $this->assertTitle('Files (File) | Drupal');
69
70     // Translate the label of the view.
71     $this->drupalGet($translation_url);
72     $edit = [
73       'translation[config_names][views.view.files][label]' => 'Fichiers',
74     ];
75     $this->drupalPostForm(NULL, $edit, t('Save translation'));
76
77     // Check if the label is translated.
78     $this->drupalGet($edit_url, ['language' => \Drupal::languageManager()->getLanguage('fr')]);
79     $this->assertTitle('Files (File) | Drupal');
80     $this->assertNoText('Fichiers');
81   }
82
83 }