Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / field / tests / src / Kernel / Migrate / d6 / MigrateFieldOptionTranslationTest.php
1 <?php
2
3 namespace Drupal\Tests\field\Kernel\Migrate\d6;
4
5 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
6
7 /**
8  * Migrate field option translations.
9  *
10  * @group migrate_drupal_6
11  */
12 class MigrateFieldOptionTranslationTest extends MigrateDrupal6TestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = [
18     'config_translation',
19     'language',
20     'locale',
21     'menu_ui',
22   ];
23
24   /**
25    * {@inheritdoc}
26    */
27   protected function setUp() {
28     parent::setUp();
29     $this->executeMigrations([
30       'language',
31       'd6_field',
32       'd6_field_option_translation',
33     ]);
34   }
35
36   /**
37    * Tests the Drupal 6 field to Drupal 8 migration.
38    */
39   public function testFieldOptionTranslation() {
40     $language_manager = $this->container->get('language_manager');
41
42     // Test a select list with allowed values of key only.
43     /** @var \Drupal\language\Config\LanguageConfigOverride $config_translation */
44     $config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.storage.node.field_test_integer_selectlist');
45     $allowed_values = [
46       1 => [
47         'label' => 'fr - 2341',
48       ],
49       3 => [
50         'label' => 'fr - 4123',
51       ],
52     ];
53     $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
54
55     $config_translation = $language_manager->getLanguageConfigOverride('zu', 'field.storage.node.field_test_integer_selectlist');
56     $allowed_values = [
57       1 => [
58         'label' => 'zu - 2341',
59       ],
60     ];
61     $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
62
63     // Test a select list with allowed values of key|label.
64     $config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.storage.node.field_test_string_selectlist');
65     $allowed_values = [
66       0 => [
67         'label' => 'Noir',
68       ],
69     ];
70     $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
71
72     $config_translation = $language_manager->getLanguageConfigOverride('zu', 'field.storage.node.field_test_string_selectlist');
73     $allowed_values = [
74       0 => [
75         'label' => 'Okumnyama',
76       ],
77       1 => [
78         'label' => 'Mhlophe',
79       ],
80     ];
81     $this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
82   }
83
84 }