Version 1
[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_instance'] = [
64       [
65         'id' => '14',
66         'field_id' => '1',
67         'field_name' => 'comment_body',
68         'entity_type' => 'comment',
69         'bundle' => 'comment_node_test_content_type',
70         'data' => 'a:0:{}',
71         'deleted' => '0',
72       ],
73     ];
74     $tests[0]['source_data']['field_data_comment_body'] = [
75       [
76         'entity_type' => 'comment',
77         'bundle' => 'comment_node_test_content_type',
78         'deleted' => '0',
79         'entity_id' => '1',
80         'revision_id' => '1',
81         'language' => 'und',
82         'delta' => '0',
83         'comment_body_value' => 'This is a comment',
84         'comment_body_format' => 'filtered_html',
85       ],
86     ];
87
88     // The expected results.
89     $tests[0]['expected_data'] = [
90       [
91         'cid' => '1',
92         'pid' => '0',
93         'nid' => '1',
94         'uid' => '1',
95         'subject' => 'A comment',
96         'hostname' => '::1',
97         'created' => '1421727536',
98         'changed' => '1421727536',
99         'status' => '1',
100         'thread' => '01/',
101         'name' => 'admin',
102         'mail' => '',
103         'homepage' => '',
104         'language' => 'und',
105         'comment_body' => [
106           [
107             'value' => 'This is a comment',
108             'format' => 'filtered_html',
109           ],
110         ],
111       ],
112     ];
113
114     return $tests;
115   }
116
117 }