dc9948956318cc2ded877a85b4c2126e46ee2f74
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Plugin / migrate / source / d7 / CommentTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d7;
4
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
6
7 /**
8  * Tests D7 comment source plugin.
9  *
10  * @covers \Drupal\comment\Plugin\migrate\source\d7\Comment
11  * @group comment
12  */
13 class CommentTest extends MigrateSqlSourceTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['comment', 'migrate_drupal'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public function providerSource() {
24     $tests = [];
25
26     // The source data.
27     $tests[0]['source_data']['comment'] = [
28       [
29         'cid' => '1',
30         'pid' => '0',
31         'nid' => '1',
32         'uid' => '1',
33         'subject' => 'A comment',
34         'hostname' => '::1',
35         'created' => '1421727536',
36         'changed' => '1421727536',
37         'status' => '1',
38         'thread' => '01/',
39         'name' => 'admin',
40         'mail' => '',
41         'homepage' => '',
42         'language' => 'und',
43       ],
44     ];
45     $tests[0]['source_data']['node'] = [
46       [
47         'nid' => '1',
48         'vid' => '1',
49         'type' => 'test_content_type',
50         'language' => 'en',
51         'title' => 'A Node',
52         'uid' => '1',
53         'status' => '1',
54         'created' => '1421727515',
55         'changed' => '1421727515',
56         'comment' => '2',
57         'promote' => '1',
58         'sticky' => '0',
59         'tnid' => '0',
60         'translate' => '0',
61       ],
62     ];
63     $tests[0]['source_data']['field_config'] = [
64       [
65         'id' => '1',
66         'translatable' => '0',
67       ],
68       [
69         'id' => '2',
70         'translatable' => '1',
71       ],
72     ];
73     $tests[0]['source_data']['field_config_instance'] = [
74       [
75         'id' => '14',
76         'field_id' => '1',
77         'field_name' => 'comment_body',
78         'entity_type' => 'comment',
79         'bundle' => 'comment_node_test_content_type',
80         'data' => 'a:0:{}',
81         'deleted' => '0',
82       ],
83       [
84         'id' => '15',
85         'field_id' => '2',
86         'field_name' => 'subject_field',
87         'entity_type' => 'comment',
88         'bundle' => 'comment_node_test_content_type',
89         'data' => 'a:0:{}',
90         'deleted' => '0',
91       ],
92     ];
93     $tests[0]['source_data']['field_data_comment_body'] = [
94       [
95         'entity_type' => 'comment',
96         'bundle' => 'comment_node_test_content_type',
97         'deleted' => '0',
98         'entity_id' => '1',
99         'revision_id' => '1',
100         'language' => 'und',
101         'delta' => '0',
102         'comment_body_value' => 'This is a comment',
103         'comment_body_format' => 'filtered_html',
104       ],
105     ];
106     $tests[0]['source_data']['field_data_subject_field'] = [
107       [
108         'entity_type' => 'comment',
109         'bundle' => 'comment_node_test_content_type',
110         'deleted' => '0',
111         'entity_id' => '1',
112         'revision_id' => '1',
113         'language' => 'und',
114         'delta' => '0',
115         'subject_field_value' => 'A comment (subject_field)',
116         'subject_field_format' => NULL,
117       ],
118     ];
119     $tests[0]['source_data']['system'] = [
120       [
121         'name' => 'title',
122         'type' => 'module',
123         'status' => 1,
124       ],
125     ];
126
127     // The expected results.
128     $tests[0]['expected_data'] = [
129       [
130         'cid' => '1',
131         'pid' => '0',
132         'nid' => '1',
133         'uid' => '1',
134         'subject' => 'A comment (subject_field)',
135         'hostname' => '::1',
136         'created' => '1421727536',
137         'changed' => '1421727536',
138         'status' => '1',
139         'thread' => '01/',
140         'name' => 'admin',
141         'mail' => '',
142         'homepage' => '',
143         'language' => 'und',
144         'comment_body' => [
145           [
146             'value' => 'This is a comment',
147             'format' => 'filtered_html',
148           ],
149         ],
150       ],
151     ];
152
153     return $tests;
154   }
155
156 }