You are here

public function ConfigTranslationUiTest::testSequenceTranslation in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::testSequenceTranslation()

Tests the sequence data type translation.

File

core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php, line 921

Class

ConfigTranslationUiTest
Translate settings and entities to various languages.

Namespace

Drupal\Tests\config_translation\Functional

Code

public function testSequenceTranslation() {
  $this
    ->drupalLogin($this->adminUser);

  /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
  $config_factory = $this->container
    ->get('config.factory');
  $expected = [
    'kitten',
    'llama',
    'elephant',
  ];
  $actual = $config_factory
    ->getEditable('config_translation_test.content')
    ->get('animals');
  $this
    ->assertEquals($expected, $actual);
  $edit = [
    'translation[config_names][config_translation_test.content][content][value]' => '<p><strong>Hello World</strong> - FR</p>',
    'translation[config_names][config_translation_test.content][animals][0]' => 'kitten - FR',
    'translation[config_names][config_translation_test.content][animals][1]' => 'llama - FR',
    'translation[config_names][config_translation_test.content][animals][2]' => 'elephant - FR',
  ];
  $this
    ->drupalGet('admin/config/media/file-system/translate/fr/add');
  $this
    ->submitForm($edit, 'Save translation');
  $this->container
    ->get('language.config_factory_override')
    ->setLanguage(new Language([
    'id' => 'fr',
  ]));
  $expected = [
    'kitten - FR',
    'llama - FR',
    'elephant - FR',
  ];
  $actual = $config_factory
    ->get('config_translation_test.content')
    ->get('animals');
  $this
    ->assertEquals($expected, $actual);
}