d373bb25873cd258fcc927a317a2609062e91ea0
[yaffs-website] / web / core / modules / menu_link_content / tests / src / Kernel / Plugin / migrate / source / d6 / MenuLinkTranslationTest.php
1 <?php
2
3 namespace Drupal\Tests\menu_link_content\Kernel\Plugin\migrate\source\d6;
4
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
6
7 /**
8  * Tests menu link translation source plugin.
9  *
10  * @covers \Drupal\menu_link_content\Plugin\migrate\source\d6\MenuLinkTranslation
11  * @group menu_link_content
12  */
13 class MenuLinkTranslationTest extends MigrateSqlSourceTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['menu_link_content', 'migrate_drupal'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public function providerSource() {
24     $test = [];
25     $test[0]['source_data']['menu_links'] = [
26       [
27         'menu_name' => 'menu-test-menu',
28         'mlid' => 138,
29         'plid' => 0,
30         'link_path' => 'admin',
31         'router_path' => 'admin',
32         'link_title' => 'Test 1',
33         'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 1";}}',
34         'module' => 'menu',
35         'hidden' => 0,
36         'external' => 0,
37         'has_children' => 1,
38         'expanded' => 0,
39         'weight' => 15,
40         'depth' => 1,
41         'customized' => 1,
42         'p1' => '138',
43         'p2' => '0',
44         'p3' => '0',
45         'p4' => '0',
46         'p5' => '0',
47         'p6' => '0',
48         'p7' => '0',
49         'p8' => '0',
50         'p9' => '0',
51         'updated' => '0',
52       ],
53       [
54         'menu_name' => 'menu-test-menu',
55         'mlid' => 139,
56         'plid' => 138,
57         'link_path' => 'admin/modules',
58         'router_path' => 'admin/modules',
59         'link_title' => 'Test 2',
60         'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 2";}}',
61         'module' => 'menu',
62         'hidden' => 0,
63         'external' => 0,
64         'has_children' => 0,
65         'expanded' => 0,
66         'weight' => 12,
67         'depth' => 2,
68         'customized' => 1,
69         'p1' => '138',
70         'p2' => '139',
71         'p3' => '0',
72         'p4' => '0',
73         'p5' => '0',
74         'p6' => '0',
75         'p7' => '0',
76         'p8' => '0',
77         'p9' => '0',
78         'updated' => '0',
79       ],
80       [
81         'menu_name' => 'menu-test-menu',
82         'mlid' => 140,
83         'plid' => 0,
84         'link_path' => 'https://www.drupal.org',
85         'router_path' => 'admin/modules',
86         'link_title' => 'Test 2',
87         'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 2";}}',
88         'module' => 'menu',
89         'hidden' => 0,
90         'external' => 0,
91         'has_children' => 0,
92         'expanded' => 0,
93         'weight' => 12,
94         'depth' => 2,
95         'customized' => 1,
96         'p1' => '0',
97         'p2' => '0',
98         'p3' => '0',
99         'p4' => '0',
100         'p5' => '0',
101         'p6' => '0',
102         'p7' => '0',
103         'p8' => '0',
104         'p9' => '0',
105         'updated' => '0',
106       ],
107       [
108         'menu_name' => 'menu-test-menu',
109         'mlid' => 141,
110         'plid' => 0,
111         'link_path' => 'https://api.drupal.org/api/drupal/8.3.x',
112         'router_path' => 'admin/modules',
113         'link_title' => 'Test 3',
114         'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:16:"Test menu link 3";}}',
115         'module' => 'menu',
116         'hidden' => 0,
117         'external' => 0,
118         'has_children' => 0,
119         'expanded' => 0,
120         'weight' => 12,
121         'depth' => 2,
122         'customized' => 1,
123         'p1' => '0',
124         'p2' => '0',
125         'p3' => '0',
126         'p4' => '0',
127         'p5' => '0',
128         'p6' => '0',
129         'p7' => '0',
130         'p8' => '0',
131         'p9' => '0',
132         'updated' => '0',
133       ],
134     ];
135     $test[0]['source_data']['i18n_strings'] = [
136       [
137         'lid' => 1,
138         'objectid' => 139,
139         'type' => 'item',
140         'property' => 'title',
141         'objectindex' => 0,
142         'format' => 0,
143       ],
144       [
145         'lid' => 2,
146         'objectid' => 139,
147         'type' => 'item',
148         'property' => 'description',
149         'objectindex' => 0,
150         'format' => 0,
151       ],
152       [
153         'lid' => 3,
154         'objectid' => 140,
155         'type' => 'item',
156         'property' => 'description',
157         'objectindex' => 0,
158         'format' => 0,
159       ],
160       [
161         'lid' => 4,
162         'objectid' => 141,
163         'type' => 'item',
164         'property' => 'title',
165         'objectindex' => 0,
166         'format' => 0,
167       ],
168     ];
169     $test[0]['source_data']['locales_target'] = [
170       [
171         'lid' => 1,
172         'language' => 'fr',
173         'translation' => 'fr - title translation',
174         'plid' => 0,
175         'plural' => 0,
176         'i18n_status' => 0,
177       ],
178       [
179         'lid' => 2,
180         'language' => 'fr',
181         'translation' => 'fr - description translation',
182         'plid' => 0,
183         'plural' => 0,
184         'i18n_status' => 0,
185       ],
186       [
187         'lid' => 3,
188         'language' => 'zu',
189         'translation' => 'zu - description translation',
190         'plid' => 0,
191         'plural' => 0,
192         'i18n_status' => 0,
193       ],
194       [
195         'lid' => 4,
196         'language' => 'zu',
197         'translation' => 'zu - title translation',
198         'plid' => 0,
199         'plural' => 0,
200         'i18n_status' => 0,
201       ],
202     ];
203
204     $test[0]['expected_results'] = [
205       [
206         'menu_name' => 'menu-test-menu',
207         'mlid' => 139,
208         'property' => 'title',
209         'language' => 'fr',
210         'link_title' => 'Test 2',
211         'description' => 'Test menu link 2',
212         'title_translated' => 'fr - title translation',
213         'description_translated' => 'fr - description translation',
214       ],
215       [
216         'menu_name' => 'menu-test-menu',
217         'mlid' => 139,
218         'property' => 'description',
219         'language' => 'fr',
220         'link_title' => 'Test 2',
221         'description' => 'Test menu link 2',
222         'title_translated' => 'fr - title translation',
223         'description_translated' => 'fr - description translation',
224       ],
225       [
226         'menu_name' => 'menu-test-menu',
227         'mlid' => 140,
228         'property' => 'description',
229         'language' => 'zu',
230         'link_title' => 'Test 2',
231         'description' => 'Test menu link 2',
232         'title_translated' => NULL,
233         'description_translated' => 'zu - description translation',
234       ],
235       [
236         'menu_name' => 'menu-test-menu',
237         'mlid' => 141,
238         'property' => 'title',
239         'language' => 'zu',
240         'link_title' => 'Test 3',
241         'description' => 'Test menu link 3',
242         'title_translated' => 'zu - title translation',
243         'description_translated' => NULL,
244       ],
245     ];
246
247     return $test;
248   }
249
250 }