3 namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d6;
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
8 * Tests the field option translation source plugin.
10 * @covers \Drupal\field\Plugin\migrate\source\d6\FieldOptionTranslation
11 * @group migrate_drupal
13 class FieldOptionTranslationTest extends MigrateSqlSourceTestBase {
18 public static $modules = ['field', 'migrate_drupal'];
23 public function providerSource() {
27 $test[0]['source_data']['content_node_field'] = [
29 'field_name' => 'field_test_text_single_checkbox',
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:"";}',
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:"";}',
47 $test[0]['source_data']['content_node_field_instance'] = [
49 'field_name' => 'field_test_text_single_checkbox',
50 'type_name' => 'story',
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',
59 'global_settings' => 'a:0;',
60 'widget_settings' => 'a:0;',
61 'display_settings' => 'a:0;',
64 'field_name' => 'field_test_integer_selectlist',
65 'type_name' => 'story',
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',
74 'global_settings' => 'a:0;',
75 'widget_settings' => 'a:0;',
76 'display_settings' => 'a:0;',
80 $test[0]['source_data']['i18n_strings'] = [
83 'objectid' => 'field_test_text_single_checkbox',
85 'property' => 'option_0',
91 'objectid' => 'field_test_text_single_checkbox',
93 'property' => 'option_1',
99 'objectid' => 'field_test_integer_selectlist',
101 'property' => 'option_1234',
107 'objectid' => 'field_test_integer_selectlist',
109 'property' => 'option_4123',
114 $test[0]['source_data']['locales_target'] = [
117 'translation' => "fr - Hello",
125 'translation' => 'fr - Goodbye',
133 'translation' => "fr - 4444",
141 'translation' => 'fr - 5555',
149 $test[0]['expected_results'] = [
151 'field_name' => 'field_test_text_single_checkbox',
153 'widget_type' => 'optionwidgets_onoff',
154 'global_settings' => [
155 'allowed_values' => 'Off\nHello',
156 'allowed_values_php' => '',
158 'text_processing' => '0',
161 'property' => 'option_0',
162 'objectid' => 'field_test_text_single_checkbox',
164 'translation' => 'fr - Hello',
172 'field_name' => 'field_test_text_single_checkbox',
174 'widget_type' => 'optionwidgets_onoff',
175 'global_settings' => [
176 'allowed_values' => 'Off\nHello',
177 'allowed_values_php' => '',
179 'text_processing' => '0',
182 'property' => 'option_1',
183 'objectid' => 'field_test_text_single_checkbox',
185 'translation' => 'fr - Goodbye',
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',
202 'allowed_values_php' => '',
205 'property' => 'option_1234',
206 'objectid' => 'field_test_integer_selectlist',
208 'translation' => 'fr - 4444',
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',
225 'allowed_values_php' => '',
228 'property' => 'option_4123',
229 'objectid' => 'field_test_integer_selectlist',
231 'translation' => 'fr - 5555',