public function MigrateFieldOptionTranslationTest::testFieldOptionTranslation in Drupal 9
Same name in this branch
- 9 core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
- 9 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
- 8 core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldOptionTranslationTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldOptionTranslationTest::testFieldOptionTranslation()
- 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\d7Code
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 = [
0 => [
'label' => 'Haute',
],
1 => [
'label' => 'Moyenne',
],
2 => [
'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 = [
0 => [
'label' => 'Hár',
],
1 => [
'label' => 'Miðlungs',
],
2 => [
'label' => 'Lágt',
],
];
$this
->assertSame($allowed_values, $config_translation
->get('settings.allowed_values'));
$config_translation = $language_manager
->getLanguageConfigOverride('fr', 'field.storage.node.field_boolean');
$this
->assertNull($config_translation
->get('settings.allowed_values'));
$config_translation = $language_manager
->getLanguageConfigOverride('is', 'field.storage.node.field_boolean');
$allowed_values = [
0 => [
0 => 'Off',
1 => '1',
],
1 => [
0 => 'Off',
1 => '1',
],
];
$this
->assertSame($allowed_values, $config_translation
->get('settings.allowed_values'));
$config_translation = $language_manager
->getLanguageConfigOverride('fr', 'field.storage.node.field_checkbox');
$allowed_values = [
0 => [
0 => 'Stop',
1 => 'Go',
],
1 => [
0 => 'Stop',
1 => 'Go',
],
];
$this
->assertSame($allowed_values, $config_translation
->get('settings.allowed_values'));
$config_translation = $language_manager
->getLanguageConfigOverride('is', 'field.storage.node.field_checkbox');
$allowed_values = [
0 => [
0 => 'Stop',
1 => 'Go',
],
1 => [
0 => 'Stop',
1 => 'Go',
],
];
$this
->assertSame($allowed_values, $config_translation
->get('settings.allowed_values'));
// Ensure that the count query works as expected.
$this
->assertCount(20, $this
->getMigration('d7_field_option_translation')
->getSourcePlugin());
}