Debian Codegraph @

tests/phpunit/includes/logging/MoveLogFormatterTest.php

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