Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / migrate / tests / src / Kernel / HighWaterNotJoinableTest.php
1 <?php
2
3 namespace Drupal\Tests\migrate\Kernel;
4
5 /**
6  * Tests the high water handling.
7  *
8  * @covers \Drupal\migrate_high_water_test\Plugin\migrate\source\HighWaterTest
9  * @group migrate
10  */
11 class HighWaterNotJoinableTest extends MigrateSqlSourceTestBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public static $modules = ['migrate', 'migrate_drupal', 'migrate_high_water_test'];
17
18   /**
19    * {@inheritdoc}
20    */
21   public function providerSource() {
22     $tests = [];
23
24     // Test high water when the map is not joinable.
25     // The source data.
26     $tests[0]['source_data']['high_water_node'] = [
27       [
28         'id' => 1,
29         'title' => 'Item 1',
30         'changed' => 1,
31       ],
32       [
33         'id' => 2,
34         'title' => 'Item 2',
35         'changed' => 2,
36       ],
37       [
38         'id' => 3,
39         'title' => 'Item 3',
40         'changed' => 3,
41       ],
42     ];
43
44     // The expected results.
45     $tests[0]['expected_data'] = [
46       [
47         'id' => 2,
48         'title' => 'Item 2',
49         'changed' => 2,
50       ],
51       [
52         'id' => 3,
53         'title' => 'Item 3',
54         'changed' => 3,
55       ],
56     ];
57
58     // The expected count is the count returned by the query before the query
59     // is modified by SqlBase::initializeIterator().
60     $tests[0]['expected_count'] = 3;
61     $tests[0]['configuration'] = [
62       'high_water_property' => [
63         'name' => 'changed',
64       ],
65     ];
66     $tests[0]['high_water'] = $tests[0]['source_data']['high_water_node'][0]['changed'];
67
68     // Test high water initialized to NULL.
69     $tests[1]['source_data'] = $tests[0]['source_data'];
70     $tests[1]['expected_data'] = [
71       [
72         'id' => 1,
73         'title' => 'Item 1',
74         'changed' => 1,
75       ],
76       [
77         'id' => 2,
78         'title' => 'Item 2',
79         'changed' => 2,
80       ],
81       [
82         'id' => 3,
83         'title' => 'Item 3',
84         'changed' => 3,
85       ],
86     ];
87     $tests[1]['expected_count'] = $tests[0]['expected_count'];
88     $tests[1]['configuration'] = $tests[0]['configuration'];
89     $tests[1]['high_water'] = NULL;
90
91     // Test high water initialized to an empty string.
92     $tests[2]['source_data'] = $tests[0]['source_data'];
93     $tests[2]['expected_data'] = [
94       [
95         'id' => 1,
96         'title' => 'Item 1',
97         'changed' => 1,
98       ],
99       [
100         'id' => 2,
101         'title' => 'Item 2',
102         'changed' => 2,
103       ],
104       [
105         'id' => 3,
106         'title' => 'Item 3',
107         'changed' => 3,
108       ],
109     ];
110     $tests[2]['expected_count'] = $tests[0]['expected_count'];
111     $tests[2]['configuration'] = $tests[0]['configuration'];
112     $tests[2]['high_water'] = '';
113
114     return $tests;
115   }
116
117 }