ff5993e6231ce4ce48ca23bf7cfde5f1045b5bfd
[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         'entity_type' => 'node',
66         'bundle' => 'page',
67         'field_name' => 'body',
68         'label' => 'hidden',
69         'type' => 'text_with_summary',
70         'formatter_type' => 'text_default',
71         'settings' => [],
72         'module' => 'text',
73         'weight' => 0,
74         'view_mode' => 'default',
75       ],
76       [
77         'entity_type' => 'node',
78         'bundle' => 'page',
79         'field_name' => 'body',
80         'label' => 'hidden',
81         'type' => 'text_with_summary',
82         'formatter_type' => 'text_summary_or_trimmed',
83         'settings' => [
84           'trim_length' => 600,
85         ],
86         'module' => 'text',
87         'weight' => 0,
88         'view_mode' => 'teaser',
89       ],
90     ];
91
92     return $tests;
93   }
94
95 }