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