Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / field / tests / src / Kernel / Plugin / migrate / source / d7 / FieldInstancePerViewModeTest.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 per view mode source plugin.
9  *
10  * @covers \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode
11  * @group field
12  */
13 class FieldInstancePerViewModeTest 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
44     $tests[0]['source_data']['field_config'] = [
45       [
46         'id' => '2',
47         'field_name' => 'body',
48         'type' => 'text_with_summary',
49         'module' => 'text',
50         'active' => '1',
51         'storage_type' => 'field_sql_storage',
52         'storage_module' => 'field_sql_storage',
53         'storage_active' => '1',
54         'locked' => '0',
55         'data' => 'a:7:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:8:"settings";a:0:{}s:12:"translatable";i:0;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:"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";s:1:"1";}s:2:"id";s:2:"25";}',
56         'cardinality' => '1',
57         'translatable' => '0',
58         'deleted' => '0',
59       ],
60     ];
61
62     // The expected results.
63     $tests[0]['expected_data'] = [
64       [
65         'id' => '2',
66         'field_id' => '2',
67         'field_name' => 'body',
68         'entity_type' => 'node',
69         'bundle' => 'page',
70         '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:"";}',
71         'deleted' => '0',
72         'type' => 'text_with_summary',
73         'view_mode' => 'default',
74         'formatter' => [
75           'label' => 'hidden',
76           'type' => 'text_default',
77           'settings' => [],
78           'module' => 'text',
79           'weight' => 0,
80         ],
81         'field_definition' => [
82           'id' => '2',
83           'field_name' => 'body',
84           'type' => 'text_with_summary',
85           'module' => 'text',
86           'active' => '1',
87           'storage_type' => 'field_sql_storage',
88           'storage_module' => 'field_sql_storage',
89           'storage_active' => '1',
90           'locked' => '0',
91           'data' => 'a:7:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:8:"settings";a:0:{}s:12:"translatable";i:0;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:"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";s:1:"1";}s:2:"id";s:2:"25";}',
92           'cardinality' => '1',
93           'translatable' => '0',
94           'deleted' => '0',
95         ],
96         'instances' => [
97           [
98             'id' => '2',
99             'field_id' => '2',
100             'field_name' => 'body',
101             'entity_type' => 'node',
102             'bundle' => 'page',
103             '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:"";}',
104             'deleted' => '0',
105             'type' => 'text_with_summary',
106             'translatable' => '0',
107           ],
108         ],
109       ],
110       [
111         'id' => '2',
112         'field_id' => '2',
113         'field_name' => 'body',
114         'entity_type' => 'node',
115         'bundle' => 'page',
116         '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:"";}',
117         'deleted' => '0',
118         'type' => 'text_with_summary',
119         'formatter' => [
120           'label' => 'hidden',
121           'type' => 'text_summary_or_trimmed',
122           'settings' => [
123             'trim_length' => 600,
124           ],
125           'module' => 'text',
126           'weight' => 0,
127         ],
128         'view_mode' => 'teaser',
129         'field_definition' => [
130           'id' => '2',
131           'field_name' => 'body',
132           'type' => 'text_with_summary',
133           'module' => 'text',
134           'active' => '1',
135           'storage_type' => 'field_sql_storage',
136           'storage_module' => 'field_sql_storage',
137           'storage_active' => '1',
138           'locked' => '0',
139           'data' => 'a:7:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:8:"settings";a:0:{}s:12:"translatable";i:0;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:"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";s:1:"1";}s:2:"id";s:2:"25";}',
140           'cardinality' => '1',
141           'translatable' => '0',
142           'deleted' => '0',
143         ],
144         'instances' => [
145           [
146             'id' => '2',
147             'field_id' => '2',
148             'field_name' => 'body',
149             'entity_type' => 'node',
150             'bundle' => 'page',
151             '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:"";}',
152             'deleted' => '0',
153             'type' => 'text_with_summary',
154             'translatable' => '0',
155           ],
156         ],
157       ],
158     ];
159
160     return $tests;
161   }
162
163 }