942391ebd64d4f1f9898e7d8aa3aec8fbff0ff74
[yaffs-website] / web / core / modules / field / tests / src / Kernel / Plugin / migrate / source / d7 / FieldInstanceTest.php
1 <?php
2
3 namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d7;
4
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
6
7 /**
8  * Tests D7 field instance source plugin.
9  *
10  * @covers \Drupal\field\Plugin\migrate\source\d7\FieldInstance
11  * @group field
12  */
13 class FieldInstanceTest extends MigrateSqlSourceTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['field', 'migrate_drupal'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public function providerSource() {
24     $tests = [
25       [
26         'source_data' => [],
27         'expected_data' => [],
28       ],
29     ];
30
31     // The source data.
32     $tests[0]['source_data']['field_config_instance'] = [
33       [
34         'id' => '2',
35         'field_id' => '2',
36         'field_name' => 'body',
37         'entity_type' => 'node',
38         'bundle' => 'page',
39         'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}',
40         'deleted' => '0',
41       ],
42     ];
43     $tests[0]['source_data']['field_config'] = [
44       [
45         'id' => '2',
46         'field_name' => 'body',
47         'type' => 'text_with_summary',
48         'module' => 'text',
49         'active' => '1',
50         'storage_type' => 'field_sql_storage',
51         'storage_module' => 'field_sql_storage',
52         'storage_active' => '1',
53         'locked' => '0',
54         'data' => 'a:6:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:12:"translatable";b:0;s:8:"settings";a:0:{}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";i:1;}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}}',
55         'cardinality' => '1',
56         'translatable' => '0',
57         'deleted' => '0',
58       ],
59     ];
60
61     // The expected results.
62     $tests[0]['expected_data'] = [
63       [
64         'id' => '2',
65         'field_id' => '2',
66         'field_name' => 'body',
67         'entity_type' => 'node',
68         'bundle' => 'page',
69         'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}',
70         'deleted' => '0',
71         'type' => 'text_with_summary',
72         'label' => 'Body',
73         'widget' => [
74           'type' => 'text_textarea_with_summary',
75           'settings' => [
76             'rows' => 20,
77             'summary_rows' => 5,
78           ],
79           'weight' => -4,
80           'module' => 'text',
81         ],
82         'settings' => [
83           'display_summary' => TRUE,
84           'text_processing' => '1',
85           'user_register_form' => FALSE,
86         ],
87         'display' => [
88           'default' => [
89             'label' => 'hidden',
90             'type' => 'text_default',
91             'settings' => [],
92             'module' => 'text',
93             'weight' => 0,
94           ],
95           'teaser' => [
96             'label' => 'hidden',
97             'type' => 'text_summary_or_trimmed',
98             'settings' => [
99               'trim_length' => 600,
100             ],
101             'module' => 'text',
102             'weight' => 0,
103           ],
104         ],
105         'required' => FALSE,
106         'description' => '',
107         'field_definition' => [
108           'id' => '2',
109           'field_name' => 'body',
110           'type' => 'text_with_summary',
111           'module' => 'text',
112           'active' => '1',
113           'storage_type' => 'field_sql_storage',
114           'storage_module' => 'field_sql_storage',
115           'storage_active' => '1',
116           'locked' => '0',
117           'data' => 'a:6:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:12:"translatable";b:0;s:8:"settings";a:0:{}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";i:1;}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}}',
118           'cardinality' => '1',
119           'translatable' => '0',
120           'deleted' => '0',
121         ],
122         'instances' => [
123           [
124             'id' => '2',
125             'field_id' => '2',
126             'field_name' => 'body',
127             'entity_type' => 'node',
128             'bundle' => 'page',
129             'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}',
130             'deleted' => '0',
131             'type' => 'text_with_summary',
132             'translatable' => '0',
133           ],
134         ],
135       ],
136     ];
137
138     return $tests;
139   }
140
141 }