Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / tests / phpunit / includes / logging / BlockLogFormatterTest.php
blob4158ea2348d2fe32898ef278e6b20de0f0791580
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 [
12 // Current log format
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' => [
23 '5::duration' => 'infinite',
24 '6::flags' => 'anononly',
28 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
29 . ' (anonymous users only)',
30 'api' => [
31 'duration' => 'infinite',
32 'flags' => [ 'anononly' ],
37 // Old legacy log
40 'type' => 'block',
41 'action' => 'block',
42 'comment' => 'Block comment',
43 'user' => 0,
44 'user_text' => 'Sysop',
45 'namespace' => NS_USER,
46 'title' => 'Logtestuser',
47 'params' => [
48 'infinite',
49 'anononly',
53 'legacy' => true,
54 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
55 . ' (anonymous users only)',
56 'api' => [
57 'duration' => 'infinite',
58 'flags' => [ 'anononly' ],
63 // Old legacy log without flag
66 'type' => 'block',
67 'action' => 'block',
68 'comment' => 'Block comment',
69 'user' => 0,
70 'user_text' => 'Sysop',
71 'namespace' => NS_USER,
72 'title' => 'Logtestuser',
73 'params' => [
74 'infinite',
78 'legacy' => true,
79 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite',
80 'api' => [
81 'duration' => 'infinite',
82 'flags' => [],
87 // Very old legacy log without duration
90 'type' => 'block',
91 'action' => 'block',
92 'comment' => 'Block comment',
93 'user' => 0,
94 'user_text' => 'Sysop',
95 'namespace' => NS_USER,
96 'title' => 'Logtestuser',
97 'params' => [],
100 'legacy' => true,
101 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite',
102 'api' => [
103 'duration' => 'infinite',
104 'flags' => [],
112 * @dataProvider provideBlockLogDatabaseRows
114 public function testBlockLogDatabaseRows( $row, $extra ) {
115 $this->doTestLogFormatter( $row, $extra );
119 * Provide different rows from the logging table to test
120 * for backward compatibility.
121 * Do not change the existing data, just add a new database row
123 public static function provideReblockLogDatabaseRows() {
124 return [
125 // Current log format
128 'type' => 'block',
129 'action' => 'reblock',
130 'comment' => 'Block comment',
131 'user' => 0,
132 'user_text' => 'Sysop',
133 'namespace' => NS_USER,
134 'title' => 'Logtestuser',
135 'params' => [
136 '5::duration' => 'infinite',
137 '6::flags' => 'anononly',
141 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
142 . ' indefinite (anonymous users only)',
143 'api' => [
144 'duration' => 'infinite',
145 'flags' => [ 'anononly' ],
150 // Old log
153 'type' => 'block',
154 'action' => 'reblock',
155 'comment' => 'Block comment',
156 'user' => 0,
157 'user_text' => 'Sysop',
158 'namespace' => NS_USER,
159 'title' => 'Logtestuser',
160 'params' => [
161 'infinite',
162 'anononly',
166 'legacy' => true,
167 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
168 . ' indefinite (anonymous users only)',
169 'api' => [
170 'duration' => 'infinite',
171 'flags' => [ 'anononly' ],
176 // Older log without flag
179 'type' => 'block',
180 'action' => 'reblock',
181 'comment' => 'Block comment',
182 'user' => 0,
183 'user_text' => 'Sysop',
184 'namespace' => NS_USER,
185 'title' => 'Logtestuser',
186 'params' => [
187 'infinite',
191 'legacy' => true,
192 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of indefinite',
193 'api' => [
194 'duration' => 'infinite',
195 'flags' => [],
203 * @dataProvider provideReblockLogDatabaseRows
205 public function testReblockLogDatabaseRows( $row, $extra ) {
206 $this->doTestLogFormatter( $row, $extra );
210 * Provide different rows from the logging table to test
211 * for backward compatibility.
212 * Do not change the existing data, just add a new database row
214 public static function provideUnblockLogDatabaseRows() {
215 return [
216 // Current log format
219 'type' => 'block',
220 'action' => 'unblock',
221 'comment' => 'Block comment',
222 'user' => 0,
223 'user_text' => 'Sysop',
224 'namespace' => NS_USER,
225 'title' => 'Logtestuser',
226 'params' => [],
229 'text' => 'Sysop unblocked Logtestuser',
230 'api' => [],
237 * @dataProvider provideUnblockLogDatabaseRows
239 public function testUnblockLogDatabaseRows( $row, $extra ) {
240 $this->doTestLogFormatter( $row, $extra );
244 * Provide different rows from the logging table to test
245 * for backward compatibility.
246 * Do not change the existing data, just add a new database row
248 public static function provideSuppressBlockLogDatabaseRows() {
249 return [
250 // Current log format
253 'type' => 'suppress',
254 'action' => 'block',
255 'comment' => 'Block comment',
256 'user' => 0,
257 'user_text' => 'Sysop',
258 'namespace' => NS_USER,
259 'title' => 'Logtestuser',
260 'params' => [
261 '5::duration' => 'infinite',
262 '6::flags' => 'anononly',
266 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
267 . ' (anonymous users only)',
268 'api' => [
269 'duration' => 'infinite',
270 'flags' => [ 'anononly' ],
275 // legacy log
278 'type' => 'suppress',
279 'action' => 'block',
280 'comment' => 'Block comment',
281 'user' => 0,
282 'user_text' => 'Sysop',
283 'namespace' => NS_USER,
284 'title' => 'Logtestuser',
285 'params' => [
286 'infinite',
287 'anononly',
291 'legacy' => true,
292 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
293 . ' (anonymous users only)',
294 'api' => [
295 'duration' => 'infinite',
296 'flags' => [ 'anononly' ],
304 * @dataProvider provideSuppressBlockLogDatabaseRows
306 public function testSuppressBlockLogDatabaseRows( $row, $extra ) {
307 $this->doTestLogFormatter( $row, $extra );
311 * Provide different rows from the logging table to test
312 * for backward compatibility.
313 * Do not change the existing data, just add a new database row
315 public static function provideSuppressReblockLogDatabaseRows() {
316 return [
317 // Current log format
320 'type' => 'suppress',
321 'action' => 'reblock',
322 'comment' => 'Block comment',
323 'user' => 0,
324 'user_text' => 'Sysop',
325 'namespace' => NS_USER,
326 'title' => 'Logtestuser',
327 'params' => [
328 '5::duration' => 'infinite',
329 '6::flags' => 'anononly',
333 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
334 . ' indefinite (anonymous users only)',
335 'api' => [
336 'duration' => 'infinite',
337 'flags' => [ 'anononly' ],
342 // Legacy format
345 'type' => 'suppress',
346 'action' => 'reblock',
347 'comment' => 'Block comment',
348 'user' => 0,
349 'user_text' => 'Sysop',
350 'namespace' => NS_USER,
351 'title' => 'Logtestuser',
352 'params' => [
353 'infinite',
354 'anononly',
358 'legacy' => true,
359 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
360 . ' indefinite (anonymous users only)',
361 'api' => [
362 'duration' => 'infinite',
363 'flags' => [ 'anononly' ],
371 * @dataProvider provideSuppressReblockLogDatabaseRows
373 public function testSuppressReblockLogDatabaseRows( $row, $extra ) {
374 $this->doTestLogFormatter( $row, $extra );