You are here

public function TranslatedViewTest::testTranslatedStrings in Drupal 8

Same name and namespace 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()

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');
}