a4d91c468611da328c6e63c19593846f6c288817
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Plugin / migrate / source / d6 / CommentSourceWithHighWaterTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d6;
4
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
6
7 /**
8  * Tests the Drupal 6 comment source w/ high water handling.
9  *
10  * @covers \Drupal\comment\Plugin\migrate\source\d6\Comment
11  *
12  * @group comment
13  */
14 class CommentSourceWithHighWaterTest extends MigrateSqlSourceTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['comment', 'migrate_drupal'];
20
21   /**
22    * {@inheritdoc}
23    */
24   public function providerSource() {
25     $tests = [];
26
27     // The source data.
28     $tests[0]['source_data']['comments'] = [
29       [
30         'cid' => 1,
31         'pid' => 0,
32         'nid' => 2,
33         'uid' => 3,
34         'subject' => 'subject value 1',
35         'comment' => 'comment value 1',
36         'hostname' => 'hostname value 1',
37         'timestamp' => 1382255613,
38         'status' => 0,
39         'thread' => '',
40         'name' => '',
41         'mail' => '',
42         'homepage' => '',
43         'format' => 'testformat1',
44         'type' => 'story',
45       ],
46       [
47         'cid' => 2,
48         'pid' => 1,
49         'nid' => 3,
50         'uid' => 4,
51         'subject' => 'subject value 2',
52         'comment' => 'comment value 2',
53         'hostname' => 'hostname value 2',
54         'timestamp' => 1382255662,
55         'status' => 0,
56         'thread' => '',
57         'name' => '',
58         'mail' => '',
59         'homepage' => '',
60         'format' => 'testformat2',
61         'type' => 'page',
62       ],
63     ];
64
65     $tests[0]['source_data']['node'] = [
66       [
67         'nid' => 2,
68         'type' => 'story',
69       ],
70       [
71         'nid' => 3,
72         'type' => 'page',
73       ],
74     ];
75
76     // The expected results.
77     $tests[0]['expected_data'] = [
78       [
79         'cid' => 2,
80         'pid' => 1,
81         'nid' => 3,
82         'uid' => 4,
83         'subject' => 'subject value 2',
84         'comment' => 'comment value 2',
85         'hostname' => 'hostname value 2',
86         'timestamp' => 1382255662,
87         'status' => 1,
88         'thread' => '',
89         'name' => '',
90         'mail' => '',
91         'homepage' => '',
92         'format' => 'testformat2',
93         'type' => 'page',
94       ],
95     ];
96
97     // The expected count is the count returned by the query before the query
98     // is modified by SqlBase::initializeIterator().
99     $tests[0]['expected_count'] = 2;
100
101     $tests[0]['configuration']['high_water_property']['name'] = 'timestamp';
102     $tests[0]['high_water'] = $tests[0]['source_data']['comments'][0]['timestamp'];
103     return $tests;
104   }
105
106 }