MediaWiki REL1_32
BlockLogFormatterTest.php
Go to the documentation of this file.
1<?php
2
7
13 public static function provideBlockLogDatabaseRows() {
14 return [
15 // Current log format
16 [
17 [
18 'type' => 'block',
19 'action' => 'block',
20 'comment' => 'Block comment',
21 'user' => 0,
22 'user_text' => 'Sysop',
23 'namespace' => NS_USER,
24 'title' => 'Logtestuser',
25 'params' => [
26 '5::duration' => 'infinite',
27 '6::flags' => 'anononly',
28 ],
29 ],
30 [
31 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
32 . ' (anonymous users only)',
33 'api' => [
34 'duration' => 'infinite',
35 'flags' => [ 'anononly' ],
36 ],
37 ],
38 ],
39
40 // Old legacy log
41 [
42 [
43 'type' => 'block',
44 'action' => 'block',
45 'comment' => 'Block comment',
46 'user' => 0,
47 'user_text' => 'Sysop',
48 'namespace' => NS_USER,
49 'title' => 'Logtestuser',
50 'params' => [
51 'infinite',
52 'anononly',
53 ],
54 ],
55 [
56 'legacy' => true,
57 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
58 . ' (anonymous users only)',
59 'api' => [
60 'duration' => 'infinite',
61 'flags' => [ 'anononly' ],
62 ],
63 ],
64 ],
65
66 // Old legacy log without flag
67 [
68 [
69 'type' => 'block',
70 'action' => 'block',
71 'comment' => 'Block comment',
72 'user' => 0,
73 'user_text' => 'Sysop',
74 'namespace' => NS_USER,
75 'title' => 'Logtestuser',
76 'params' => [
77 'infinite',
78 ],
79 ],
80 [
81 'legacy' => true,
82 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite',
83 'api' => [
84 'duration' => 'infinite',
85 'flags' => [],
86 ],
87 ],
88 ],
89
90 // Very old legacy log without duration
91 [
92 [
93 'type' => 'block',
94 'action' => 'block',
95 'comment' => 'Block comment',
96 'user' => 0,
97 'user_text' => 'Sysop',
98 'namespace' => NS_USER,
99 'title' => 'Logtestuser',
100 'params' => [],
101 ],
102 [
103 'legacy' => true,
104 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite',
105 'api' => [
106 'duration' => 'infinite',
107 'flags' => [],
108 ],
109 ],
110 ],
111 ];
112 }
113
117 public function testBlockLogDatabaseRows( $row, $extra ) {
118 $this->doTestLogFormatter( $row, $extra );
119 }
120
126 public static function provideReblockLogDatabaseRows() {
127 return [
128 // Current log format
129 [
130 [
131 'type' => 'block',
132 'action' => 'reblock',
133 'comment' => 'Block comment',
134 'user' => 0,
135 'user_text' => 'Sysop',
136 'namespace' => NS_USER,
137 'title' => 'Logtestuser',
138 'params' => [
139 '5::duration' => 'infinite',
140 '6::flags' => 'anononly',
141 ],
142 ],
143 [
144 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
145 . ' indefinite (anonymous users only)',
146 'api' => [
147 'duration' => 'infinite',
148 'flags' => [ 'anononly' ],
149 ],
150 ],
151 ],
152
153 // Old log
154 [
155 [
156 'type' => 'block',
157 'action' => 'reblock',
158 'comment' => 'Block comment',
159 'user' => 0,
160 'user_text' => 'Sysop',
161 'namespace' => NS_USER,
162 'title' => 'Logtestuser',
163 'params' => [
164 'infinite',
165 'anononly',
166 ],
167 ],
168 [
169 'legacy' => true,
170 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
171 . ' indefinite (anonymous users only)',
172 'api' => [
173 'duration' => 'infinite',
174 'flags' => [ 'anononly' ],
175 ],
176 ],
177 ],
178
179 // Older log without flag
180 [
181 [
182 'type' => 'block',
183 'action' => 'reblock',
184 'comment' => 'Block comment',
185 'user' => 0,
186 'user_text' => 'Sysop',
187 'namespace' => NS_USER,
188 'title' => 'Logtestuser',
189 'params' => [
190 'infinite',
191 ]
192 ],
193 [
194 'legacy' => true,
195 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of indefinite',
196 'api' => [
197 'duration' => 'infinite',
198 'flags' => [],
199 ],
200 ],
201 ],
202 ];
203 }
204
208 public function testReblockLogDatabaseRows( $row, $extra ) {
209 $this->doTestLogFormatter( $row, $extra );
210 }
211
217 public static function provideUnblockLogDatabaseRows() {
218 return [
219 // Current log format
220 [
221 [
222 'type' => 'block',
223 'action' => 'unblock',
224 'comment' => 'Block comment',
225 'user' => 0,
226 'user_text' => 'Sysop',
227 'namespace' => NS_USER,
228 'title' => 'Logtestuser',
229 'params' => [],
230 ],
231 [
232 'text' => 'Sysop unblocked Logtestuser',
233 'api' => [],
234 ],
235 ],
236 ];
237 }
238
242 public function testUnblockLogDatabaseRows( $row, $extra ) {
243 $this->doTestLogFormatter( $row, $extra );
244 }
245
251 public static function provideSuppressBlockLogDatabaseRows() {
252 return [
253 // Current log format
254 [
255 [
256 'type' => 'suppress',
257 'action' => 'block',
258 'comment' => 'Block comment',
259 'user' => 0,
260 'user_text' => 'Sysop',
261 'namespace' => NS_USER,
262 'title' => 'Logtestuser',
263 'params' => [
264 '5::duration' => 'infinite',
265 '6::flags' => 'anononly',
266 ],
267 ],
268 [
269 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
270 . ' (anonymous users only)',
271 'api' => [
272 'duration' => 'infinite',
273 'flags' => [ 'anononly' ],
274 ],
275 ],
276 ],
277
278 // legacy log
279 [
280 [
281 'type' => 'suppress',
282 'action' => 'block',
283 'comment' => 'Block comment',
284 'user' => 0,
285 'user_text' => 'Sysop',
286 'namespace' => NS_USER,
287 'title' => 'Logtestuser',
288 'params' => [
289 'infinite',
290 'anononly',
291 ],
292 ],
293 [
294 'legacy' => true,
295 'text' => 'Sysop blocked Logtestuser with an expiration time of indefinite'
296 . ' (anonymous users only)',
297 'api' => [
298 'duration' => 'infinite',
299 'flags' => [ 'anononly' ],
300 ],
301 ],
302 ],
303 ];
304 }
305
309 public function testSuppressBlockLogDatabaseRows( $row, $extra ) {
310 $this->doTestLogFormatter( $row, $extra );
311 }
312
318 public static function provideSuppressReblockLogDatabaseRows() {
319 return [
320 // Current log format
321 [
322 [
323 'type' => 'suppress',
324 'action' => 'reblock',
325 'comment' => 'Block comment',
326 'user' => 0,
327 'user_text' => 'Sysop',
328 'namespace' => NS_USER,
329 'title' => 'Logtestuser',
330 'params' => [
331 '5::duration' => 'infinite',
332 '6::flags' => 'anononly',
333 ],
334 ],
335 [
336 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
337 . ' indefinite (anonymous users only)',
338 'api' => [
339 'duration' => 'infinite',
340 'flags' => [ 'anononly' ],
341 ],
342 ],
343 ],
344
345 // Legacy format
346 [
347 [
348 'type' => 'suppress',
349 'action' => 'reblock',
350 'comment' => 'Block comment',
351 'user' => 0,
352 'user_text' => 'Sysop',
353 'namespace' => NS_USER,
354 'title' => 'Logtestuser',
355 'params' => [
356 'infinite',
357 'anononly',
358 ],
359 ],
360 [
361 'legacy' => true,
362 'text' => 'Sysop changed block settings for Logtestuser with an expiration time of'
363 . ' indefinite (anonymous users only)',
364 'api' => [
365 'duration' => 'infinite',
366 'flags' => [ 'anononly' ],
367 ],
368 ],
369 ],
370 ];
371 }
372
376 public function testSuppressReblockLogDatabaseRows( $row, $extra ) {
377 $this->doTestLogFormatter( $row, $extra );
378 }
379}
static provideSuppressReblockLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testSuppressBlockLogDatabaseRows( $row, $extra)
provideSuppressBlockLogDatabaseRows
static provideReblockLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testSuppressReblockLogDatabaseRows( $row, $extra)
provideSuppressReblockLogDatabaseRows
static provideUnblockLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testBlockLogDatabaseRows( $row, $extra)
provideBlockLogDatabaseRows
testReblockLogDatabaseRows( $row, $extra)
provideReblockLogDatabaseRows
static provideBlockLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testUnblockLogDatabaseRows( $row, $extra)
provideUnblockLogDatabaseRows
static provideSuppressBlockLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
doTestLogFormatter( $row, $extra)
const NS_USER
Definition Defines.php:66
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37