8503a3f581fa8b652227a61400b50c8de1f3f233
[yaffs-website] / web / core / modules / field / tests / src / Kernel / Plugin / migrate / source / d6 / FieldOptionTranslationTest.php
1 <?php
2
3 namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d6;
4
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
6
7 /**
8  * Tests the field option translation source plugin.
9  *
10  * @covers \Drupal\field\Plugin\migrate\source\d6\FieldOptionTranslation
11  * @group migrate_drupal
12  */
13 class FieldOptionTranslationTest extends MigrateSqlSourceTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['field', 'migrate_drupal'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public function providerSource() {
24     $test = [];
25
26     // The source data.
27     $test[0]['source_data']['content_node_field'] = [
28       [
29         'field_name' => 'field_test_text_single_checkbox',
30         'type' => 'text',
31         'global_settings' => 'a:4:{s:15:"text_processing";s:1:"0";s:10:"max_length";s:0:"";s:14:"allowed_values";s:10:"Off\\nHello";s:18:"allowed_values_php";s:0:"";}',
32         'required' => 0,
33         'multiple' => 0,
34         'db_storage' => 1,
35         'module' => 'text',
36       ],
37       [
38         'field_name' => 'field_test_integer_selectlist',
39         'type' => 'number_integer',
40         'global_settings' => 'a:6:{s:6:"prefix";s:0:"";s:6:"suffix";s:0:"";s:3:"min";s:0:"";s:3:"max";s:0:"";s:14:"allowed_values";s:22:"1234\\n2341\\n3412\\n4123";s:18:"allowed_values_php";s:0:"";}',
41         'required' => 0,
42         'multiple' => 0,
43         'db_storage' => 1,
44         'module' => 'text',
45       ],
46     ];
47     $test[0]['source_data']['content_node_field_instance'] = [
48       [
49         'field_name' => 'field_test_text_single_checkbox',
50         'type_name' => 'story',
51         'weight' => 1,
52         'label' => 'Text Single Checkbox Field',
53         'widget_type' => 'optionwidgets_onoff',
54         'description' => 'An example text field using a single on/off checkbox.',
55         'widget_module' => 'optionwidgets',
56         'widget_active' => 1,
57         'required' => 1,
58         'active' => 1,
59         'global_settings' => 'a:0;',
60         'widget_settings' => 'a:0;',
61         'display_settings' => 'a:0;',
62       ],
63       [
64         'field_name' => 'field_test_integer_selectlist',
65         'type_name' => 'story',
66         'weight' => 1,
67         'label' => 'Integer Select List Field',
68         'widget_type' => 'optionwidgets_select',
69         'description' => 'An example integer field using a select list.',
70         'widget_module' => 'optionwidgets',
71         'widget_active' => 1,
72         'required' => 1,
73         'active' => 1,
74         'global_settings' => 'a:0;',
75         'widget_settings' => 'a:0;',
76         'display_settings' => 'a:0;',
77       ],
78     ];
79
80     $test[0]['source_data']['i18n_strings'] = [
81       [
82         'lid' => 10,
83         'objectid' => 'field_test_text_single_checkbox',
84         'type' => 'field',
85         'property' => 'option_0',
86         'objectindex' => 0,
87         'format' => 0,
88       ],
89       [
90         'lid' => 11,
91         'objectid' => 'field_test_text_single_checkbox',
92         'type' => 'field',
93         'property' => 'option_1',
94         'objectindex' => 0,
95         'format' => 0,
96       ],
97       [
98         'lid' => 20,
99         'objectid' => 'field_test_integer_selectlist',
100         'type' => 'field',
101         'property' => 'option_1234',
102         'objectindex' => 0,
103         'format' => 0,
104       ],
105       [
106         'lid' => 21,
107         'objectid' => 'field_test_integer_selectlist',
108         'type' => 'field',
109         'property' => 'option_4123',
110         'objectindex' => 0,
111         'format' => 0,
112       ],
113     ];
114     $test[0]['source_data']['locales_target'] = [
115       [
116         'lid' => 10,
117         'translation' => "fr - Hello",
118         'language' => 'fr',
119         'plid' => 0,
120         'plural' => 0,
121         'i18n_status' => 0,
122       ],
123       [
124         'lid' => 11,
125         'translation' => 'fr - Goodbye',
126         'language' => 'fr',
127         'plid' => 0,
128         'plural' => 0,
129         'i18n_status' => 0,
130       ],
131       [
132         'lid' => 20,
133         'translation' => "fr - 4444",
134         'language' => 'fr',
135         'plid' => 0,
136         'plural' => 0,
137         'i18n_status' => 0,
138       ],
139       [
140         'lid' => 21,
141         'translation' => 'fr - 5555',
142         'language' => 'fr',
143         'plid' => 0,
144         'plural' => 0,
145         'i18n_status' => 0,
146       ],
147     ];
148
149     $test[0]['expected_results'] = [
150       [
151         'field_name' => 'field_test_text_single_checkbox',
152         'type' => 'text',
153         'widget_type' => 'optionwidgets_onoff',
154         'global_settings' => [
155           'allowed_values' => 'Off\nHello',
156           'allowed_values_php' => '',
157           'max_length' => '',
158           'text_processing' => '0',
159         ],
160         'db_columns' => '',
161         'property' => 'option_0',
162         'objectid' => 'field_test_text_single_checkbox',
163         'language' => 'fr',
164         'translation' => 'fr - Hello',
165         'objectindex' => 0,
166         'format' => 0,
167         'plid' => 0,
168         'plural' => 0,
169         'i18n_status' => 0,
170       ],
171       [
172         'field_name' => 'field_test_text_single_checkbox',
173         'type' => 'text',
174         'widget_type' => 'optionwidgets_onoff',
175         'global_settings' => [
176           'allowed_values' => 'Off\nHello',
177           'allowed_values_php' => '',
178           'max_length' => '',
179           'text_processing' => '0',
180         ],
181         'db_columns' => '',
182         'property' => 'option_1',
183         'objectid' => 'field_test_text_single_checkbox',
184         'language' => 'fr',
185         'translation' => 'fr - Goodbye',
186         'objectindex' => 0,
187         'format' => 0,
188         'plid' => 0,
189         'plural' => 0,
190         'i18n_status' => 0,
191       ],
192       [
193         'field_name' => 'field_test_integer_selectlist',
194         'type' => 'number_integer',
195         'widget_type' => 'optionwidgets_select',
196         'global_settings' => [
197           'allowed_values' => '1234\n2341\n3412\n4123',
198           'max' => '',
199           'min' => '',
200           'prefix' => '',
201           'suffix' => '',
202           'allowed_values_php' => '',
203         ],
204         'db_columns' => '',
205         'property' => 'option_1234',
206         'objectid' => 'field_test_integer_selectlist',
207         'language' => 'fr',
208         'translation' => 'fr - 4444',
209         'objectindex' => 0,
210         'format' => 0,
211         'plid' => 0,
212         'plural' => 0,
213         'i18n_status' => 0,
214       ],
215       [
216         'field_name' => 'field_test_integer_selectlist',
217         'type' => 'number_integer',
218         'widget_type' => 'optionwidgets_select',
219         'global_settings' => [
220           'allowed_values' => '1234\n2341\n3412\n4123',
221           'max' => '',
222           'min' => '',
223           'prefix' => '',
224           'suffix' => '',
225           'allowed_values_php' => '',
226         ],
227         'db_columns' => '',
228         'property' => 'option_4123',
229         'objectid' => 'field_test_integer_selectlist',
230         'language' => 'fr',
231         'translation' => 'fr - 5555',
232         'objectindex' => 0,
233         'format' => 0,
234         'plid' => 0,
235         'plural' => 0,
236         'i18n_status' => 0,
237       ],
238     ];
239     return $test;
240   }
241
242 }