Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Plugin / migrate / source / d7 / CommentEntityTranslationTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d7;
4
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
6
7 /**
8  * Tests D7 comment entity translation source plugin.
9  *
10  * @covers \Drupal\comment\Plugin\migrate\source\d7\CommentEntityTranslation
11  * @group comment
12  */
13 class CommentEntityTranslationTest extends MigrateSqlSourceTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['comment', 'migrate_drupal'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public function providerSource() {
24     $tests = [];
25
26     // The source data.
27     $tests[0]['source_data']['comment'] = [
28       [
29         'cid' => '1',
30         'pid' => '0',
31         'nid' => '1',
32         'uid' => '1',
33         'subject' => 'A comment',
34         'hostname' => '::1',
35         'created' => '1421727536',
36         'changed' => '1421727536',
37         'status' => '1',
38         'thread' => '01/',
39         'name' => 'admin',
40         'mail' => '',
41         'homepage' => '',
42         'language' => 'en',
43       ],
44     ];
45     $tests[0]['source_data']['entity_translation'] = [
46       [
47         'entity_type' => 'comment',
48         'entity_id' => 1,
49         'revision_id' => 1,
50         'language' => 'en',
51         'source' => '',
52         'uid' => 1,
53         'status' => 1,
54         'translate' => 0,
55         'created' => '1421727536',
56         'changed' => '1421727536',
57       ],
58       [
59         'entity_type' => 'comment',
60         'entity_id' => 1,
61         'revision_id' => 1,
62         'language' => 'fr',
63         'source' => 'en',
64         'uid' => 1,
65         'status' => 0,
66         'translate' => 0,
67         'created' => 1531343508,
68         'changed' => 1531343508,
69       ],
70       [
71         'entity_type' => 'comment',
72         'entity_id' => 1,
73         'revision_id' => 1,
74         'language' => 'es',
75         'source' => 'en',
76         'uid' => 2,
77         'status' => 1,
78         'translate' => 1,
79         'created' => 1531343528,
80         'changed' => 1531343528,
81       ],
82     ];
83     $tests[0]['source_data']['field_config'] = [
84       [
85         'id' => 1,
86         'field_name' => 'field_test',
87         'type' => 'text',
88         'module' => 'text',
89         'active' => 1,
90         'storage_type' => 'field_sql_storage',
91         'storage_module' => 'field_sql_storage',
92         'storage_active' => 1,
93         'locked' => 1,
94         'data' => 'a:0:{}',
95         'cardinality' => 1,
96         'translatable' => 1,
97         'deleted' => 0,
98       ],
99       [
100         'id' => 2,
101         'field_name' => 'subject_field',
102         'type' => 'text',
103         'module' => 'text',
104         'active' => 1,
105         'storage_type' => 'field_sql_storage',
106         'storage_module' => 'field_sql_storage',
107         'storage_active' => 1,
108         'locked' => 1,
109         'data' => 'a:0:{}',
110         'cardinality' => 1,
111         'translatable' => 1,
112         'deleted' => 0,
113       ],
114     ];
115     $tests[0]['source_data']['field_config_instance'] = [
116       [
117         'id' => '1',
118         'field_id' => '1',
119         'field_name' => 'field_test',
120         'entity_type' => 'comment',
121         'bundle' => 'comment_node_test_content_type',
122         'data' => 'a:0:{}',
123         'deleted' => '0',
124       ],
125       [
126         'id' => '2',
127         'field_id' => '2',
128         'field_name' => 'subject_field',
129         'entity_type' => 'comment',
130         'bundle' => 'comment_node_test_content_type',
131         'data' => 'a:0:{}',
132         'deleted' => '0',
133       ],
134     ];
135     $tests[0]['source_data']['field_data_field_test'] = [
136       [
137         'entity_type' => 'comment',
138         'bundle' => 'comment_node_test_content_type',
139         'deleted' => '0',
140         'entity_id' => '1',
141         'revision_id' => '1',
142         'language' => 'en',
143         'delta' => '0',
144         'field_test_value' => 'This is an English comment',
145         'field_test_format' => NULL,
146       ],
147       [
148         'entity_type' => 'comment',
149         'bundle' => 'comment_node_test_content_type',
150         'deleted' => '0',
151         'entity_id' => '1',
152         'revision_id' => '1',
153         'language' => 'fr',
154         'delta' => '0',
155         'field_test_value' => 'This is a French comment',
156         'field_test_format' => NULL,
157       ],
158       [
159         'entity_type' => 'comment',
160         'bundle' => 'comment_node_test_content_type',
161         'deleted' => '0',
162         'entity_id' => '1',
163         'revision_id' => '1',
164         'language' => 'es',
165         'delta' => '0',
166         'field_test_value' => 'This is a Spanish comment',
167         'field_test_format' => NULL,
168       ],
169     ];
170     $tests[0]['source_data']['field_data_subject_field'] = [
171       [
172         'entity_type' => 'comment',
173         'bundle' => 'comment_node_test_content_type',
174         'deleted' => '0',
175         'entity_id' => '1',
176         'revision_id' => '1',
177         'language' => 'en',
178         'delta' => '0',
179         'subject_field_value' => 'Comment subject in English',
180         'subject_field_format' => NULL,
181       ],
182       [
183         'entity_type' => 'comment',
184         'bundle' => 'comment_node_test_content_type',
185         'deleted' => '0',
186         'entity_id' => '1',
187         'revision_id' => '1',
188         'language' => 'fr',
189         'delta' => '0',
190         'subject_field_value' => 'Comment subject in French',
191         'subject_field_format' => NULL,
192       ],
193       [
194         'entity_type' => 'comment',
195         'bundle' => 'comment_node_test_content_type',
196         'deleted' => '0',
197         'entity_id' => '1',
198         'revision_id' => '1',
199         'language' => 'es',
200         'delta' => '0',
201         'subject_field_value' => 'Comment subject in Spanish',
202         'subject_field_format' => NULL,
203       ],
204     ];
205     $tests[0]['source_data']['node'] = [
206       [
207         'nid' => '1',
208         'vid' => '1',
209         'type' => 'test_content_type',
210         'language' => 'en',
211         'title' => 'A Node',
212         'uid' => '1',
213         'status' => '1',
214         'created' => '1421727515',
215         'changed' => '1421727515',
216         'comment' => '2',
217         'promote' => '1',
218         'sticky' => '0',
219         'tnid' => '0',
220         'translate' => '0',
221       ],
222     ];
223
224     // The expected results.
225     $tests[0]['expected_data'] = [
226       [
227         'subject' => 'A comment',
228         'entity_type' => 'comment',
229         'entity_id' => '1',
230         'revision_id' => '1',
231         'language' => 'fr',
232         'source' => 'en',
233         'uid' => '1',
234         'status' => '0',
235         'translate' => '0',
236         'created' => '1531343508',
237         'changed' => '1531343508',
238         'field_test' => [
239           [
240             'value' => 'This is a French comment',
241             'format' => NULL,
242           ],
243         ],
244         'subject_field' => [
245           [
246             'value' => 'Comment subject in French',
247             'format' => NULL,
248           ],
249         ],
250       ],
251       [
252         'subject' => 'A comment',
253         'entity_type' => 'comment',
254         'entity_id' => '1',
255         'revision_id' => '1',
256         'language' => 'es',
257         'source' => 'en',
258         'uid' => '2',
259         'status' => '1',
260         'translate' => '1',
261         'created' => '1531343528',
262         'changed' => '1531343528',
263         'field_test' => [
264           [
265             'value' => 'This is a Spanish comment',
266             'format' => NULL,
267           ],
268         ],
269         'subject_field' => [
270           [
271             'value' => 'Comment subject in Spanish',
272             'format' => NULL,
273           ],
274         ],
275       ],
276     ];
277
278     return $tests;
279   }
280
281 }