function MigrateFieldOptionTranslationTest::testFieldOptionTranslation

Same name in this branch
  1. 11.x core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
  2. 9 core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
  3. 8.9.x core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
  4. 8.9.x core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
  5. 10 core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
  6. 10 core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()

Tests the Drupal 6 field to Drupal 8 migration.

File

core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldOptionTranslationTest.php, line 41

Class

MigrateFieldOptionTranslationTest
Migrate field option translations.

Namespace

Drupal\Tests\field\Kernel\Migrate\d6

Code

public function testFieldOptionTranslation() : void {
    $language_manager = $this->container
        ->get('language_manager');
    // Test a select list with allowed values of key only.
    
    /** @var \Drupal\language\Config\LanguageConfigOverride $config_translation */
    $config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.storage.node.field_test_integer_selectlist');
    $allowed_values = [
        1 => [
            'label' => 'fr - 2341',
        ],
        3 => [
            'label' => 'fr - 4123',
        ],
    ];
    $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
    $config_translation = $language_manager->getLanguageConfigOverride('zu', 'field.storage.node.field_test_integer_selectlist');
    $allowed_values = [
        1 => [
            'label' => 'zu - 2341',
        ],
    ];
    $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
    // Test a select list with allowed values of key|label.
    $config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.storage.node.field_test_string_selectlist');
    $allowed_values = [
        0 => [
            'label' => 'Noir',
        ],
    ];
    $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
    $config_translation = $language_manager->getLanguageConfigOverride('zu', 'field.storage.node.field_test_string_selectlist');
    $allowed_values = [
        0 => [
            'label' => 'Okumnyama',
        ],
        1 => [
            'label' => 'Mhlophe',
        ],
    ];
    $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
}

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