function TranslatedViewTest::testTranslatedStrings

Same name in other branches
  1. 9 core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php \Drupal\Tests\views_ui\Functional\TranslatedViewTest::testTranslatedStrings()
  2. 10 core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php \Drupal\Tests\views_ui\Functional\TranslatedViewTest::testTranslatedStrings()
  3. 11.x core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php \Drupal\Tests\views_ui\Functional\TranslatedViewTest::testTranslatedStrings()

File

core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php, line 67

Class

TranslatedViewTest
Tests that translated strings in views UI don't override original strings.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testTranslatedStrings() {
    $translation_url = 'admin/structure/views/view/files/translate/fr/add';
    $edit_url = 'admin/structure/views/view/files';
    // Check the original string.
    $this->drupalGet($edit_url);
    $this->assertTitle('Files (File) | Drupal');
    // Translate the label of the view.
    $this->drupalGet($translation_url);
    $edit = [
        'translation[config_names][views.view.files][label]' => 'Fichiers',
    ];
    $this->drupalPostForm(NULL, $edit, t('Save translation'));
    // Check if the label is translated.
    $this->drupalGet($edit_url, [
        'language' => \Drupal::languageManager()->getLanguage('fr'),
    ]);
    $this->assertTitle('Files (File) | Drupal');
    $this->assertNoText('Fichiers');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.