3433a6a4335b4d0242abeca39c84c83e8780b081
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / MoveLogFormatterTest.php
1 <?php
2
3 class MoveLogFormatterTest extends LogFormatterTestCase {
4
5 /**
6 * Provide different rows from the logging table to test
7 * for backward compatibility.
8 * Do not change the existing data, just add a new database row
9 */
10 public static function provideMoveLogDatabaseRows() {
11 return [
12 // Current format - with redirect
13 [
14 [
15 'type' => 'move',
16 'action' => 'move',
17 'comment' => 'move comment with redirect',
18 'namespace' => NS_MAIN,
19 'title' => 'OldPage',
20 'params' => [
21 '4::target' => 'NewPage',
22 '5::noredir' => '0',
23 ],
24 ],
25 [
26 'text' => 'User moved page OldPage to NewPage',
27 'api' => [
28 'target_ns' => 0,
29 'target_title' => 'NewPage',
30 'suppressredirect' => false,
31 ],
32 ],
33 ],
34
35 // Current format - without redirect
36 [
37 [
38 'type' => 'move',
39 'action' => 'move',
40 'comment' => 'move comment',
41 'namespace' => NS_MAIN,
42 'title' => 'OldPage',
43 'params' => [
44 '4::target' => 'NewPage',
45 '5::noredir' => '1',
46 ],
47 ],
48 [
49 'text' => 'User moved page OldPage to NewPage without leaving a redirect',
50 'api' => [
51 'target_ns' => 0,
52 'target_title' => 'NewPage',
53 'suppressredirect' => true,
54 ],
55 ],
56 ],
57
58 // legacy format - with redirect
59 [
60 [
61 'type' => 'move',
62 'action' => 'move',
63 'comment' => 'move comment',
64 'namespace' => NS_MAIN,
65 'title' => 'OldPage',
66 'params' => [
67 'NewPage',
68 '',
69 ],
70 ],
71 [
72 'legacy' => true,
73 'text' => 'User moved page OldPage to NewPage',
74 'api' => [
75 'target_ns' => 0,
76 'target_title' => 'NewPage',
77 'suppressredirect' => false,
78 ],
79 ],
80 ],
81
82 // legacy format - without redirect
83 [
84 [
85 'type' => 'move',
86 'action' => 'move',
87 'comment' => 'move comment',
88 'namespace' => NS_MAIN,
89 'title' => 'OldPage',
90 'params' => [
91 'NewPage',
92 '1',
93 ],
94 ],
95 [
96 'legacy' => true,
97 'text' => 'User moved page OldPage to NewPage without leaving a redirect',
98 'api' => [
99 'target_ns' => 0,
100 'target_title' => 'NewPage',
101 'suppressredirect' => true,
102 ],
103 ],
104 ],
105
106 // old format without flag for redirect suppression
107 [
108 [
109 'type' => 'move',
110 'action' => 'move',
111 'comment' => 'move comment',
112 'namespace' => NS_MAIN,
113 'title' => 'OldPage',
114 'params' => [
115 'NewPage',
116 ],
117 ],
118 [
119 'legacy' => true,
120 'text' => 'User moved page OldPage to NewPage',
121 'api' => [
122 'target_ns' => 0,
123 'target_title' => 'NewPage',
124 'suppressredirect' => false,
125 ],
126 ],
127 ],
128 ];
129 }
130
131 /**
132 * @dataProvider provideMoveLogDatabaseRows
133 */
134 public function testMoveLogDatabaseRows( $row, $extra ) {
135 $this->doTestLogFormatter( $row, $extra );
136 }
137
138 /**
139 * Provide different rows from the logging table to test
140 * for backward compatibility.
141 * Do not change the existing data, just add a new database row
142 */
143 public static function provideMoveRedirLogDatabaseRows() {
144 return [
145 // Current format - with redirect
146 [
147 [
148 'type' => 'move',
149 'action' => 'move_redir',
150 'comment' => 'move comment with redirect',
151 'namespace' => NS_MAIN,
152 'title' => 'OldPage',
153 'params' => [
154 '4::target' => 'NewPage',
155 '5::noredir' => '0',
156 ],
157 ],
158 [
159 'text' => 'User moved page OldPage to NewPage over redirect',
160 'api' => [
161 'target_ns' => 0,
162 'target_title' => 'NewPage',
163 'suppressredirect' => false,
164 ],
165 ],
166 ],
167
168 // Current format - without redirect
169 [
170 [
171 'type' => 'move',
172 'action' => 'move_redir',
173 'comment' => 'move comment',
174 'namespace' => NS_MAIN,
175 'title' => 'OldPage',
176 'params' => [
177 '4::target' => 'NewPage',
178 '5::noredir' => '1',
179 ],
180 ],
181 [
182 'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
183 'api' => [
184 'target_ns' => 0,
185 'target_title' => 'NewPage',
186 'suppressredirect' => true,
187 ],
188 ],
189 ],
190
191 // legacy format - with redirect
192 [
193 [
194 'type' => 'move',
195 'action' => 'move_redir',
196 'comment' => 'move comment',
197 'namespace' => NS_MAIN,
198 'title' => 'OldPage',
199 'params' => [
200 'NewPage',
201 '',
202 ],
203 ],
204 [
205 'legacy' => true,
206 'text' => 'User moved page OldPage to NewPage over redirect',
207 'api' => [
208 'target_ns' => 0,
209 'target_title' => 'NewPage',
210 'suppressredirect' => false,
211 ],
212 ],
213 ],
214
215 // legacy format - without redirect
216 [
217 [
218 'type' => 'move',
219 'action' => 'move_redir',
220 'comment' => 'move comment',
221 'namespace' => NS_MAIN,
222 'title' => 'OldPage',
223 'params' => [
224 'NewPage',
225 '1',
226 ],
227 ],
228 [
229 'legacy' => true,
230 'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
231 'api' => [
232 'target_ns' => 0,
233 'target_title' => 'NewPage',
234 'suppressredirect' => true,
235 ],
236 ],
237 ],
238
239 // old format without flag for redirect suppression
240 [
241 [
242 'type' => 'move',
243 'action' => 'move_redir',
244 'comment' => 'move comment',
245 'namespace' => NS_MAIN,
246 'title' => 'OldPage',
247 'params' => [
248 'NewPage',
249 ],
250 ],
251 [
252 'legacy' => true,
253 'text' => 'User moved page OldPage to NewPage over redirect',
254 'api' => [
255 'target_ns' => 0,
256 'target_title' => 'NewPage',
257 'suppressredirect' => false,
258 ],
259 ],
260 ],
261 ];
262 }
263
264 /**
265 * @dataProvider provideMoveRedirLogDatabaseRows
266 */
267 public function testMoveRedirLogDatabaseRows( $row, $extra ) {
268 $this->doTestLogFormatter( $row, $extra );
269 }
270 }