You are here

public function MigrateFieldOptionTranslationTest::testFieldOptionTranslation in Drupal 8

Same name in this branch
  1. 8 core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
  2. 8 core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
Same name and namespace in other branches
  1. 9 core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
  2. 10 core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()

Tests the Drupal 7 field option translation to Drupal 8 migration.

File

core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldOptionTranslationTest.php, line 49

Class

MigrateFieldOptionTranslationTest
Migrate field option translations.

Namespace

Drupal\Tests\field\Kernel\Migrate\d7

Code

public function testFieldOptionTranslation() {
  $language_manager = $this->container
    ->get('language_manager');

  /** @var \Drupal\language\Config\LanguageConfigOverride $config_translation */
  $config_translation = $language_manager
    ->getLanguageConfigOverride('fr', 'field.storage.node.field_color');
  $allowed_values = [
    0 => [
      'label' => 'Verte',
    ],
    1 => [
      'label' => 'Noire',
    ],
    2 => [
      'label' => 'Blanche',
    ],
  ];
  $this
    ->assertSame($allowed_values, $config_translation
    ->get('settings.allowed_values'));
  $config_translation = $language_manager
    ->getLanguageConfigOverride('is', 'field.storage.node.field_color');
  $allowed_values = [
    0 => [
      'label' => 'Grænn',
    ],
    1 => [
      'label' => 'Svartur',
    ],
    2 => [
      'label' => 'Hvítur',
    ],
  ];
  $this
    ->assertSame($allowed_values, $config_translation
    ->get('settings.allowed_values'));
  $config_translation = $language_manager
    ->getLanguageConfigOverride('fr', 'field.storage.node.field_rating');
  $allowed_values = [
    1 => [
      'label' => 'Haute',
    ],
    2 => [
      'label' => 'Moyenne',
    ],
    3 => [
      'label' => 'Faible',
    ],
  ];
  $this
    ->assertSame($allowed_values, $config_translation
    ->get('settings.allowed_values'));
  $config_translation = $language_manager
    ->getLanguageConfigOverride('is', 'field.storage.node.field_rating');
  $allowed_values = [
    1 => [
      'label' => 'Hár',
    ],
    2 => [
      'label' => 'Miðlungs',
    ],
    3 => [
      'label' => 'Lágt',
    ],
  ];
  $this
    ->assertSame($allowed_values, $config_translation
    ->get('settings.allowed_values'));

  // Ensure that the count query works as expected.
  $this
    ->assertCount(16, $this
    ->getMigration('d7_field_option_translation')
    ->getSourcePlugin());
}