Pull merge.
[yaffs-website] / web / core / modules / taxonomy / tests / src / Kernel / Plugin / migrate / source / d6 / TermLocalizedTranslationTest.php
1 <?php
2
3 namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
4
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
6
7 /**
8  * Tests D6 i18n term localized source plugin.
9  *
10  * @covers \Drupal\taxonomy\Plugin\migrate\source\d6\TermLocalizedTranslation
11  * @group taxonomy
12  */
13 class TermLocalizedTranslationTest extends MigrateSqlSourceTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['taxonomy', 'migrate_drupal'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public function providerSource() {
24     $tests = [];
25
26     // The source data.
27     $tests[0]['source_data']['term_data'] = [
28       [
29         'tid' => 1,
30         'vid' => 5,
31         'name' => 'name value 1',
32         'description' => 'description value 1',
33         'weight' => 0,
34         'language' => NULL,
35       ],
36       [
37         'tid' => 2,
38         'vid' => 6,
39         'name' => 'name value 2',
40         'description' => 'description value 2',
41         'weight' => 0,
42         'language' => NULL,
43       ],
44       [
45         'tid' => 3,
46         'vid' => 6,
47         'name' => 'name value 3',
48         'description' => 'description value 3',
49         'weight' => 0,
50         'language' => NULL,
51       ],
52       [
53         'tid' => 4,
54         'vid' => 5,
55         'name' => 'name value 4',
56         'description' => 'description value 4',
57         'weight' => 1,
58         'language' => NULL,
59       ],
60     ];
61     $tests[0]['source_data']['term_hierarchy'] = [
62       [
63         'tid' => 1,
64         'parent' => 0,
65       ],
66       [
67         'tid' => 2,
68         'parent' => 0,
69       ],
70       [
71         'tid' => 3,
72         'parent' => 0,
73       ],
74       [
75         'tid' => 4,
76         'parent' => 1,
77       ],
78     ];
79     $tests[0]['source_data']['i18n_strings'] = [
80       [
81         'lid' => 6,
82         'objectid' => 1,
83         'type' => 'term',
84         'property' => 'name',
85         'objectindex' => '1',
86         'format' => 0,
87       ],
88       [
89         'lid' => 7,
90         'objectid' => 1,
91         'type' => 'term',
92         'property' => 'description',
93         'objectindex' => '1',
94         'format' => 0,
95       ],
96       [
97         'lid' => 8,
98         'objectid' => 3,
99         'type' => 'term',
100         'property' => 'name',
101         'objectindex' => '3',
102         'format' => 0,
103       ],
104     ];
105     $tests[0]['source_data']['locales_target'] = [
106       [
107         'lid' => 6,
108         'language' => 'fr',
109         'translation' => 'fr - name value 1 translation',
110         'plid' => 0,
111         'plural' => 0,
112         'i18n_status' => 0,
113       ],
114       [
115         'lid' => 7,
116         'language' => 'fr',
117         'translation' => 'fr - description value 1 translation',
118         'plid' => 0,
119         'plural' => 0,
120         'i18n_status' => 0,
121       ],
122       [
123         'lid' => 8,
124         'language' => 'zu',
125         'translation' => 'zu - description value 2 translation',
126         'plid' => 0,
127         'plural' => 0,
128         'i18n_status' => 0,
129       ],
130     ];
131
132     // The expected results.
133     $tests[0]['expected_data'] = [
134       [
135         'tid' => 1,
136         'vid' => 5,
137         'name' => 'name value 1',
138         'description' => 'description value 1',
139         'weight' => 0,
140         'parent' => [0],
141         'property' => 'name',
142         'language' => 'fr',
143         'name_translated' => 'fr - name value 1 translation',
144         'description_translated' => 'fr - description value 1 translation',
145       ],
146       [
147         'tid' => 1,
148         'vid' => 5,
149         'name' => 'name value 1',
150         'description' => 'description value 1',
151         'weight' => 0,
152         'parent' => [0],
153         'property' => 'description',
154         'language' => 'fr',
155         'name_translated' => 'fr - name value 1 translation',
156         'description_translated' => 'fr - description value 1 translation',
157       ],
158       [
159         'tid' => 3,
160         'vid' => 6,
161         'name' => 'name value 3',
162         'description' => 'description value 3',
163         'weight' => 0,
164         'parent' => [0],
165         'property' => 'name',
166         'language' => 'zu',
167         'name_translated' => 'zu - description value 2 translation',
168         'description_translated' => NULL,
169       ],
170     ];
171
172     $tests[0]['expected_count'] = NULL;
173     // Empty configuration will return terms for all vocabularies.
174     $tests[0]['configuration'] = [];
175
176     return $tests;
177   }
178
179 }