Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / tests / phpunit / includes / logging / BlockLogFormatterTest.php
blobc7dc641d23c071c449ae29d57a84a6867ca28e6d
1 <?php
3 class BlockLogFormatterTest extends LogFormatterTestCase {
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 provideBlockLogDatabaseRows() {
11 return array(
12 // Current log format
13 array(
14 array(
15 'type' => 'block',
16 'action' => 'block',
17 'comment' => 'Block comment',
18 'user' => 0,
19 'user_text' => 'Sysop',
20 'namespace' => NS_USER,
21 'title' => 'Logtestuser',
22 'params' => array(
23 '5::duration' => 'infinite',
24 '6::flags' => 'anononly',
27 array(
28 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite (anonymous users only)',
29 'api' => array(
30 'duration' => 'infinite',
31 'flags' => array( 'anononly' ),
36 // Old legacy log
37 array(
38 array(
39 'type' => 'block',
40 'action' => 'block',
41 'comment' => 'Block comment',
42 'user' => 0,
43 'user_text' => 'Sysop',
44 'namespace' => NS_USER,
45 'title' => 'Logtestuser',
46 'params' => array(
47 'infinite',
48 'anononly',
51 array(
52 'legacy' => true,
53 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite (anonymous users only)',
54 'api' => array(
55 'duration' => 'infinite',
56 'flags' => array( 'anononly' ),
61 // Old legacy log without flag
62 array(
63 array(
64 'type' => 'block',
65 'action' => 'block',
66 'comment' => 'Block comment',
67 'user' => 0,
68 'user_text' => 'Sysop',
69 'namespace' => NS_USER,
70 'title' => 'Logtestuser',
71 'params' => array(
72 'infinite',
75 array(
76 'legacy' => true,
77 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite',
78 'api' => array(
79 'duration' => 'infinite',
80 'flags' => array(),
85 // Very old legacy log without duration
86 array(
87 array(
88 'type' => 'block',
89 'action' => 'block',
90 'comment' => 'Block comment',
91 'user' => 0,
92 'user_text' => 'Sysop',
93 'namespace' => NS_USER,
94 'title' => 'Logtestuser',
95 'params' => array(),
97 array(
98 'legacy' => true,
99 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite',
100 'api' => array(
101 'duration' => 'infinite',
102 'flags' => array(),
110 * @dataProvider provideBlockLogDatabaseRows
112 public function testBlockLogDatabaseRows( $row, $extra ) {
113 $this->doTestLogFormatter( $row, $extra );
117 * Provide different rows from the logging table to test
118 * for backward compatibility.
119 * Do not change the existing data, just add a new database row
121 public static function provideReblockLogDatabaseRows() {
122 return array(
123 // Current log format
124 array(
125 array(
126 'type' => 'block',
127 'action' => 'reblock',
128 'comment' => 'Block comment',
129 'user' => 0,
130 'user_text' => 'Sysop',
131 'namespace' => NS_USER,
132 'title' => 'Logtestuser',
133 'params' => array(
134 '5::duration' => 'infinite',
135 '6::flags' => 'anononly',
138 array(
139 'text' => 'Sysop changed block settings for Logtestuser with an expiry time of'
140 . ' indefinite (anonymous users only)',
141 'api' => array(
142 'duration' => 'infinite',
143 'flags' => array( 'anononly' ),
148 // Old log
149 array(
150 array(
151 'type' => 'block',
152 'action' => 'reblock',
153 'comment' => 'Block comment',
154 'user' => 0,
155 'user_text' => 'Sysop',
156 'namespace' => NS_USER,
157 'title' => 'Logtestuser',
158 'params' => array(
159 'infinite',
160 'anononly',
163 array(
164 'legacy' => true,
165 'text' => 'Sysop changed block settings for Logtestuser with an expiry time of'
166 . ' indefinite (anonymous users only)',
167 'api' => array(
168 'duration' => 'infinite',
169 'flags' => array( 'anononly' ),
174 // Older log without flag
175 array(
176 array(
177 'type' => 'block',
178 'action' => 'reblock',
179 'comment' => 'Block comment',
180 'user' => 0,
181 'user_text' => 'Sysop',
182 'namespace' => NS_USER,
183 'title' => 'Logtestuser',
184 'params' => array(
185 'infinite',
188 array(
189 'legacy' => true,
190 'text' => 'Sysop changed block settings for Logtestuser with an expiry time of indefinite',
191 'api' => array(
192 'duration' => 'infinite',
193 'flags' => array(),
201 * @dataProvider provideReblockLogDatabaseRows
203 public function testReblockLogDatabaseRows( $row, $extra ) {
204 $this->doTestLogFormatter( $row, $extra );
208 * Provide different rows from the logging table to test
209 * for backward compatibility.
210 * Do not change the existing data, just add a new database row
212 public static function provideUnblockLogDatabaseRows() {
213 return array(
214 // Current log format
215 array(
216 array(
217 'type' => 'block',
218 'action' => 'unblock',
219 'comment' => 'Block comment',
220 'user' => 0,
221 'user_text' => 'Sysop',
222 'namespace' => NS_USER,
223 'title' => 'Logtestuser',
224 'params' => array(),
226 array(
227 'text' => 'Sysop unblocked Logtestuser',
228 'api' => array(),
235 * @dataProvider provideUnblockLogDatabaseRows
237 public function testUnblockLogDatabaseRows( $row, $extra ) {
238 $this->doTestLogFormatter( $row, $extra );
242 * Provide different rows from the logging table to test
243 * for backward compatibility.
244 * Do not change the existing data, just add a new database row
246 public static function provideSuppressBlockLogDatabaseRows() {
247 return array(
248 // Current log format
249 array(
250 array(
251 'type' => 'suppress',
252 'action' => 'block',
253 'comment' => 'Block comment',
254 'user' => 0,
255 'user_text' => 'Sysop',
256 'namespace' => NS_USER,
257 'title' => 'Logtestuser',
258 'params' => array(
259 '5::duration' => 'infinite',
260 '6::flags' => 'anononly',
263 array(
264 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite (anonymous users only)',
265 'api' => array(
266 'duration' => 'infinite',
267 'flags' => array( 'anononly' ),
272 // legacy log
273 array(
274 array(
275 'type' => 'suppress',
276 'action' => 'block',
277 'comment' => 'Block comment',
278 'user' => 0,
279 'user_text' => 'Sysop',
280 'namespace' => NS_USER,
281 'title' => 'Logtestuser',
282 'params' => array(
283 'infinite',
284 'anononly',
287 array(
288 'legacy' => true,
289 'text' => 'Sysop blocked Logtestuser with an expiry time of indefinite (anonymous users only)',
290 'api' => array(
291 'duration' => 'infinite',
292 'flags' => array( 'anononly' ),
300 * @dataProvider provideSuppressBlockLogDatabaseRows
302 public function testSuppressBlockLogDatabaseRows( $row, $extra ) {
303 $this->doTestLogFormatter( $row, $extra );
307 * Provide different rows from the logging table to test
308 * for backward compatibility.
309 * Do not change the existing data, just add a new database row
311 public static function provideSuppressReblockLogDatabaseRows() {
312 return array(
313 // Current log format
314 array(
315 array(
316 'type' => 'suppress',
317 'action' => 'reblock',
318 'comment' => 'Block comment',
319 'user' => 0,
320 'user_text' => 'Sysop',
321 'namespace' => NS_USER,
322 'title' => 'Logtestuser',
323 'params' => array(
324 '5::duration' => 'infinite',
325 '6::flags' => 'anononly',
328 array(
329 'text' => 'Sysop changed block settings for Logtestuser with an expiry time of'
330 . ' indefinite (anonymous users only)',
331 'api' => array(
332 'duration' => 'infinite',
333 'flags' => array( 'anononly' ),
338 // Legacy format
339 array(
340 array(
341 'type' => 'suppress',
342 'action' => 'reblock',
343 'comment' => 'Block comment',
344 'user' => 0,
345 'user_text' => 'Sysop',
346 'namespace' => NS_USER,
347 'title' => 'Logtestuser',
348 'params' => array(
349 'infinite',
350 'anononly',
353 array(
354 'legacy' => true,
355 'text' => 'Sysop changed block settings for Logtestuser with an expiry time of'
356 . ' indefinite (anonymous users only)',
357 'api' => array(
358 'duration' => 'infinite',
359 'flags' => array( 'anononly' ),
367 * @dataProvider provideSuppressReblockLogDatabaseRows
369 public function testSuppressReblockLogDatabaseRows( $row, $extra ) {
370 $this->doTestLogFormatter( $row, $extra );