7use Wikimedia\TestingAccessWrapper;
18 return Maintenance::class;
30 $obj = $this->getMockForAbstractClass( $className );
32 return TestingAccessWrapper::newFromObject( $obj );
44 foreach ( $outputs as $data ) {
45 if ( is_array( $data ) ) {
46 list( $msg, $channel ) = $data;
51 $this->maintenance->output( $msg, $channel );
58 [ [
"" ],
"",
false ],
59 [ [
"foo" ],
"foo",
false ],
60 [ [
"foo",
"bar" ],
"foobar",
false ],
61 [ [
"foo\n" ],
"foo\n",
false ],
62 [ [
"foo\n\n" ],
"foo\n\n",
false ],
63 [ [
"foo\nbar" ],
"foo\nbar",
false ],
64 [ [
"foo\nbar\n" ],
"foo\nbar\n",
false ],
65 [ [
"foo\n",
"bar\n" ],
"foo\nbar\n",
false ],
66 [ [
"",
"foo",
"",
"\n",
"ba",
"",
"r\n" ],
"foo\nbar\n",
false ],
67 [ [
"",
"foo",
"",
"\nb",
"a",
"",
"r\n" ],
"foo\nbar\n",
false ],
68 [ [ [
"foo",
"bazChannel" ] ],
"foo",
true ],
69 [ [ [
"foo\n",
"bazChannel" ] ],
"foo",
true ],
75 [ [ [
"foo\n\n",
"bazChannel" ] ],
"foo\n",
true ],
76 [ [ [
"foo\nbar",
"bazChannel" ] ],
"foo\nbar",
true ],
77 [ [ [
"foo\nbar\n",
"bazChannel" ] ],
"foo\nbar",
true ],
80 [
"foo\n",
"bazChannel" ],
81 [
"bar\n",
"bazChannel" ],
89 [
"foo",
"bazChannel" ],
91 [
"\n",
"bazChannel" ],
92 [
"ba",
"bazChannel" ],
94 [
"r\n",
"bazChannel" ],
101 [
"",
"bazChannel" ],
102 [
"foo",
"bazChannel" ],
103 [
"",
"bazChannel" ],
104 [
"\nb",
"bazChannel" ],
105 [
"a",
"bazChannel" ],
106 [
"",
"bazChannel" ],
107 [
"r\n",
"bazChannel" ],
114 [
"foo",
"bazChannel" ],
115 [
"bar",
"bazChannel" ],
116 [
"qux",
"quuxChannel" ],
117 [
"corge",
"bazChannel" ],
119 "foobar\nqux\ncorge",
124 [
"foo",
"bazChannel" ],
125 [
"bar\n",
"bazChannel" ],
126 [
"qux\n",
"quuxChannel" ],
127 [
"corge",
"bazChannel" ],
129 "foobar\nqux\ncorge",
135 [
"bar",
"bazChannel" ],
137 [
"quux",
"bazChannel" ],
144 [
"foo",
"bazChannel" ],
146 [
"qux",
"bazChannel" ],
160 [ [
"foo",
"",
"bar" ],
"foobar",
false ],
161 [ [
"foo",
false,
"bar" ],
"foobar",
false ],
164 [
"qux",
"quuxChannel" ],
174 [
"foo",
"bazChannel" ],
175 [
"",
"bazChannel" ],
176 [
"bar",
"bazChannel" ],
183 [
"foo",
"bazChannel" ],
184 [
false,
"bazChannel" ],
185 [
"bar",
"bazChannel" ],
197 foreach ( $outputs as $data ) {
198 if ( is_array( $data ) ) {
199 list( $msg, $channel ) = $data;
204 $this->maintenance->outputChanneled( $msg, $channel );
211 [ [
"" ],
"\n",
false ],
212 [ [
"foo" ],
"foo\n",
false ],
213 [ [
"foo",
"bar" ],
"foo\nbar\n",
false ],
214 [ [
"foo\nbar" ],
"foo\nbar\n",
false ],
215 [ [
"",
"foo",
"",
"\nb",
"a",
"",
"r" ],
"\nfoo\n\n\nb\na\n\nr\n",
false ],
216 [ [ [
"foo",
"bazChannel" ] ],
"foo",
true ],
219 [
"foo\nbar",
"bazChannel" ]
226 [
"foo",
"bazChannel" ],
227 [
"bar",
"bazChannel" ],
234 [
"",
"bazChannel" ],
235 [
"foo",
"bazChannel" ],
236 [
"",
"bazChannel" ],
237 [
"\nb",
"bazChannel" ],
238 [
"a",
"bazChannel" ],
239 [
"",
"bazChannel" ],
240 [
"r",
"bazChannel" ],
247 [
"foo",
"bazChannel" ],
248 [
"bar",
"bazChannel" ],
249 [
"qux",
"quuxChannel" ],
250 [
"corge",
"bazChannel" ],
252 "foobar\nqux\ncorge",
257 [
"foo",
"bazChannel" ],
258 [
"bar",
"bazChannel" ],
259 [
"qux",
"quuxChannel" ],
260 [
"corge",
"bazChannel" ],
262 "foobar\nqux\ncorge",
267 [
"foo",
"bazChannel" ],
270 [
"corge",
"bazChannel" ],
272 "foo\nbar\nqux\ncorge",
278 [
"bar",
"bazChannel" ],
280 [
"quux",
"bazChannel" ],
282 "foo\nbar\nqux\nquux",
287 [
"foo",
"bazChannel" ],
289 [
"qux",
"bazChannel" ],
292 "foo\nbar\nqux\nquux\n",
303 [ [
"foo",
"",
"bar" ],
"foo\n\nbar\n",
false ],
304 [ [
"foo",
false,
"bar" ],
"foo\nbar\n",
false ],
309 $this->maintenance->cleanupChanneled();
314 $this->maintenance->output(
"foo" );
315 $this->maintenance->cleanupChanneled();
320 $this->maintenance->output(
"foo",
null );
321 $this->maintenance->cleanupChanneled();
326 $this->maintenance->output(
"foo",
"bazChannel" );
327 $this->maintenance->cleanupChanneled();
332 $this->maintenance->output(
"foo\n" );
333 $this->maintenance->cleanupChanneled();
338 $this->maintenance->output(
"foo\n",
null );
339 $this->maintenance->cleanupChanneled();
344 $this->maintenance->output(
"foo\n",
"bazChannel" );
345 $this->maintenance->cleanupChanneled();
350 $this->maintenance->outputChanneled(
"foo" );
351 $this->maintenance->cleanupChanneled();
356 $this->maintenance->outputChanneled(
"foo",
null );
357 $this->maintenance->cleanupChanneled();
362 $this->maintenance->outputChanneled(
"foo",
"bazChannel" );
363 $this->maintenance->cleanupChanneled();
370 $this->maintenance->output(
"foo" );
371 $m2->output(
"bar" );
373 $this->assertEquals(
"foobar", $this->getActualOutput(),
374 "Output before shutdown simulation (m2)" );
375 $m2->cleanupChanneled();
382 $this->maintenance->output(
"foo",
null );
383 $m2->output(
"bar",
null );
385 $this->assertEquals(
"foobar", $this->getActualOutput(),
386 "Output before shutdown simulation (m2)" );
387 $m2->cleanupChanneled();
394 $this->maintenance->output(
"foo",
"bazChannel" );
395 $m2->output(
"bar",
"bazChannel" );
397 $this->assertEquals(
"foobar", $this->getActualOutput(),
398 "Output before shutdown simulation (m2)" );
399 $m2->cleanupChanneled();
406 $this->maintenance->output(
"foo\n",
null );
407 $m2->output(
"bar\n",
null );
409 $this->assertEquals(
"foo\nbar\n", $this->getActualOutput(),
410 "Output before shutdown simulation (m2)" );
411 $m2->cleanupChanneled();
418 $this->maintenance->output(
"foo\n",
"bazChannel" );
419 $m2->output(
"bar\n",
"bazChannel" );
421 $this->assertEquals(
"foobar", $this->getActualOutput(),
422 "Output before shutdown simulation (m2)" );
423 $m2->cleanupChanneled();
430 $this->maintenance->outputChanneled(
"foo" );
431 $m2->outputChanneled(
"bar" );
433 $this->assertEquals(
"foo\nbar\n", $this->getActualOutput(),
434 "Output before shutdown simulation (m2)" );
435 $m2->cleanupChanneled();
442 $this->maintenance->outputChanneled(
"foo",
null );
443 $m2->outputChanneled(
"bar",
null );
445 $this->assertEquals(
"foo\nbar\n", $this->getActualOutput(),
446 "Output before shutdown simulation (m2)" );
447 $m2->cleanupChanneled();
454 $this->maintenance->outputChanneled(
"foo",
"bazChannel" );
455 $m2->outputChanneled(
"bar",
"bazChannel" );
457 $this->assertEquals(
"foobar", $this->getActualOutput(),
458 "Output before shutdown simulation (m2)" );
459 $m2->cleanupChanneled();
466 $this->maintenance->outputChanneled(
"foo",
"bazChannel" );
467 $m2->outputChanneled(
"bar",
"bazChannel" );
469 $this->assertEquals(
"foobar", $this->getActualOutput(),
470 "Output before first cleanup" );
471 $this->maintenance->cleanupChanneled();
472 $this->assertEquals(
"foobar\n", $this->getActualOutput(),
473 "Output after first cleanup" );
474 $m2->cleanupChanneled();
475 $this->assertEquals(
"foobar\n\n", $this->getActualOutput(),
476 "Output after second cleanup" );
478 $m2->cleanupChanneled();
486 $this->assertInstanceOf(
'Config', $this->maintenance->getConfig() );
489 $this->maintenance->getConfig()
497 $conf = $this->createMock(
'Config' );
498 $this->maintenance->setConfig( $conf );
499 $this->assertSame( $conf, $this->maintenance->getConfig() );
506 $m2->addOption(
'multi',
'This option does stuff',
false,
true,
false,
true );
507 $m2->loadWithArgv( [
'--multi',
'this1',
'--multi',
'this2' ] );
509 $this->assertEquals( [
'this1',
'this2' ], $m2->getOption(
'multi' ) );
510 $this->assertEquals( [ [
'multi',
'this1' ], [
'multi',
'this2' ] ],
511 $m2->orderedOptions );
513 $m2->cleanupChanneled();
517 $m2->addOption(
'multi',
'This option does stuff',
false,
false,
false,
true );
518 $m2->loadWithArgv( [
'--multi',
'--multi' ] );
520 $this->assertEquals( [ 1, 1 ], $m2->getOption(
'multi' ) );
521 $this->assertEquals( [ [
'multi', 1 ], [
'multi', 1 ] ], $m2->orderedOptions );
523 $m2->cleanupChanneled();
528 $m2->addOption(
'multi',
'This option doesn\'t actually support multiple occurrences' );
529 $m2->loadWithArgv( [
'--multi=yo' ] );
531 $this->assertEquals(
'yo', $m2->getOption(
'multi' ) );
532 $this->assertEquals( [ [
'multi',
'yo' ] ], $m2->orderedOptions );
534 $m2->cleanupChanneled();
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending)
Asserts the output before and after simulating shutdown.
testSetConfig()
Maintenance::setConfig.
testMultipleMaintenanceObjectsInteractionOutputChanneled()
testCleanupChanneledAfterOutputWChannel()
testCleanupChanneledAfterNLOutputWChannel()
testCleanupChanneledAfterNLOutput()
testCleanupChanneledAfterOutputChanneledWChannel()
provideOutputChanneledData()
testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel()
testCleanupChanneledAfterOutputChanneledWNullChannel()
testCleanupChanneledAfterNLOutputWNullChannel()
testMultipleMaintenanceObjectsInteractionOutputWNullChannel()
testCleanupChanneledAfterOutputWNullChannel()
testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel()
testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel()
testCleanupChanneledAfterOutputChanneledWOChannel()
testCleanupChanneledAfterOutput()
testMultipleMaintenanceObjectsInteractionOutputWChannelNL()
testOutput( $outputs, $expected, $extraNL)
provideOutputData
testGetConfig()
Maintenance::getConfig.
testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL()
testMultipleMaintenanceObjectsInteractionOutput()
testCleanupChanneledClean()
testMultipleMaintenanceObjectsInteractionOutputWChannel()
testOutputChanneled( $outputs, $expected, $extraNL)
provideOutputChanneledData
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
processing should stop and the error should be shown to the user * false