3 // It would be great if we were able to use PHPUnit's getMockForAbstractClass
4 // instead of the MaintenanceFixup hack below. However, we cannot do
5 // without changing the visibility and without working around hacks in
8 // For the same reason, we cannot just use FakeMaintenance.
11 * makes parts of the API of Maintenance that is hidden by protected visibily
12 * visible for testing, and makes up for a stream closing hack in Maintenance.php.
14 * This class is solely used for being able to test Maintenance right now
15 * without having to apply major refactorings to fix some design issues in
16 * Maintenance.php. Before adding more functions here, please consider whether
17 * this approach is correct, or a refactoring Maintenance to separate concers
18 * is more appropriate.
20 * Upon refactoring, keep in mind that besides the maintenance scrits themselves
21 * and tests right here, also at least Extension:Maintenance make use of
24 * Due to a hack in Maintenance.php using register_shutdown_function, be sure to
25 * finally call simulateShutdown on MaintenanceFixup instance before a test
29 class MaintenanceFixup
extends Maintenance
{
31 // --- Making up for the register_shutdown_function hack in Maintenance.php
34 * The test case that generated this instance.
36 * This member is motivated by allowing the destructor to check whether or not
37 * the test failed, in order to avoid unnecessary nags about omitted shutdown
39 * But as it is already available, we also usi it to flagging tests as failed
41 * @var MediaWikiTestCase
46 * shutdownSimulated === true iff simulateShutdown has done it's work
50 private $shutdownSimulated = false;
53 * Simulates what Maintenance wants to happen at script's end.
55 public function simulateShutdown() {
57 if ( $this->shutdownSimulated
) {
58 $this->testCase
->fail( __METHOD__
. " called more than once" );
61 // The cleanup action.
62 $this->outputChanneled( false );
64 // Bookkeeping that we simulated the clean up.
65 $this->shutdownSimulated
= true;
68 // Note that the "public" here does not change visibility
69 public function outputChanneled( $msg, $channel = null ) {
70 if ( $this->shutdownSimulated
) {
71 if ( $msg !== false ) {
72 $this->testCase
->fail( "Already past simulated shutdown, but msg is "
73 . "not false. Did the hack in Maintenance.php change? Please "
74 . "adapt the test case or Maintenance.php" );
77 // The current call is the one registered via register_shutdown_function.
78 // We can safely ignore it, as we simulated this one via simulateShutdown
79 // before (if we did not, the destructor of this instance will warn about
84 return call_user_func_array ( array( "parent", __FUNCTION__
), func_get_args() );
88 * Safety net around register_shutdown_function of Maintenance.php
90 public function __destruct() {
91 if ( ! $this->shutdownSimulated
) {
92 // Someone generated a MaintenanceFixup instance without calling
93 // simulateShutdown. We'd have to raise a PHPUnit exception to correctly
94 // flag this illegal usage. However, we are already in a destruktor, which
95 // would trigger undefined behaviour. Hence, we can only report to the
96 // error output :( Hopefully people read the PHPUnit output.
97 $name = $this->testCase
->getName();
98 fwrite( STDERR
, "ERROR! Instance of " . __CLASS__
. " for test $name "
99 . "destructed without calling simulateShutdown method. Call "
100 . "simulateShutdown on the instance before it gets destructed." );
103 // The following guard is required, as PHP does not offer default destructors :(
104 if ( is_callable( "parent::__destruct" ) ) {
105 parent
::__destruct();
109 public function __construct( MediaWikiTestCase
$testCase ) {
110 parent
::__construct();
111 $this->testCase
= $testCase;
116 // --- Making protected functions visible for test
118 public function output( $out, $channel = null ) {
119 // Just to make PHP not nag about signature mismatches, we copied
120 // Maintenance::output signature. However, we do not use (or rely on)
121 // those variables. Instead we pass to Maintenance::output whatever we
122 // receive at runtime.
123 return call_user_func_array ( array( "parent", __FUNCTION__
), func_get_args() );
128 // --- Requirements for getting instance of abstract class
130 public function execute() {
131 $this->testCase
->fail( __METHOD__
. " called unexpectedly" );
136 class MaintenanceTest
extends MediaWikiTestCase
{
140 * The main Maintenance instance that is used for testing.
142 * @var MaintenanceFixup
147 protected function setUp() {
149 $this->m
= new MaintenanceFixup( $this );
152 protected function tearDown() {
154 $this->m
->simulateShutdown();
162 * asserts the output before and after simulating shutdown
164 * This function simulates shutdown of self::m.
166 * @param $preShutdownOutput string: expected output before simulating shutdown
167 * @param $expectNLAppending bool: Whether or not shutdown simulation is expected
168 * to add a newline to the output. If false, $preShutdownOutput is the
169 * expected output after shutdown simulation. Otherwise,
170 * $preShutdownOutput with an appended newline is the expected output
171 * after shutdown simulation.
173 private function assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending ) {
175 $this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
176 "Output before shutdown simulation" );
178 $this->m
->simulateShutdown();
181 $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ?
"\n" : "" );
182 $this->expectOutputString( $postShutdownOutput );
186 // Although the following tests do not seem to be too consistent (compare for
187 // example the newlines within the test.*StringString tests, or the
188 // test.*Intermittent.* tests), the objective of these tests is not to describe
189 // consistent behaviour, but rather currently existing behaviour.
192 function testOutputEmpty() {
193 $this->m
->output( "" );
194 $this->assertOutputPrePostShutdown( "", false );
197 function testOutputString() {
198 $this->m
->output( "foo" );
199 $this->assertOutputPrePostShutdown( "foo", false );
202 function testOutputStringString() {
203 $this->m
->output( "foo" );
204 $this->m
->output( "bar" );
205 $this->assertOutputPrePostShutdown( "foobar", false );
208 function testOutputStringNL() {
209 $this->m
->output( "foo\n" );
210 $this->assertOutputPrePostShutdown( "foo\n", false );
213 function testOutputStringNLNL() {
214 $this->m
->output( "foo\n\n" );
215 $this->assertOutputPrePostShutdown( "foo\n\n", false );
218 function testOutputStringNLString() {
219 $this->m
->output( "foo\nbar" );
220 $this->assertOutputPrePostShutdown( "foo\nbar", false );
223 function testOutputStringNLStringNL() {
224 $this->m
->output( "foo\nbar\n" );
225 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
228 function testOutputStringNLStringNLLinewise() {
229 $this->m
->output( "foo\n" );
230 $this->m
->output( "bar\n" );
231 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
234 function testOutputStringNLStringNLArbitrary() {
235 $this->m
->output( "" );
236 $this->m
->output( "foo" );
237 $this->m
->output( "" );
238 $this->m
->output( "\n" );
239 $this->m
->output( "ba" );
240 $this->m
->output( "" );
241 $this->m
->output( "r\n" );
242 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
245 function testOutputStringNLStringNLArbitraryAgain() {
246 $this->m
->output( "" );
247 $this->m
->output( "foo" );
248 $this->m
->output( "" );
249 $this->m
->output( "\nb" );
250 $this->m
->output( "a" );
251 $this->m
->output( "" );
252 $this->m
->output( "r\n" );
253 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
256 function testOutputWNullChannelEmpty() {
257 $this->m
->output( "", null );
258 $this->assertOutputPrePostShutdown( "", false );
261 function testOutputWNullChannelString() {
262 $this->m
->output( "foo", null );
263 $this->assertOutputPrePostShutdown( "foo", false );
266 function testOutputWNullChannelStringString() {
267 $this->m
->output( "foo", null );
268 $this->m
->output( "bar", null );
269 $this->assertOutputPrePostShutdown( "foobar", false );
272 function testOutputWNullChannelStringNL() {
273 $this->m
->output( "foo\n", null );
274 $this->assertOutputPrePostShutdown( "foo\n", false );
277 function testOutputWNullChannelStringNLNL() {
278 $this->m
->output( "foo\n\n", null );
279 $this->assertOutputPrePostShutdown( "foo\n\n", false );
282 function testOutputWNullChannelStringNLString() {
283 $this->m
->output( "foo\nbar", null );
284 $this->assertOutputPrePostShutdown( "foo\nbar", false );
287 function testOutputWNullChannelStringNLStringNL() {
288 $this->m
->output( "foo\nbar\n", null );
289 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
292 function testOutputWNullChannelStringNLStringNLLinewise() {
293 $this->m
->output( "foo\n", null );
294 $this->m
->output( "bar\n", null );
295 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
298 function testOutputWNullChannelStringNLStringNLArbitrary() {
299 $this->m
->output( "", null );
300 $this->m
->output( "foo", null );
301 $this->m
->output( "", null );
302 $this->m
->output( "\n", null );
303 $this->m
->output( "ba", null );
304 $this->m
->output( "", null );
305 $this->m
->output( "r\n", null );
306 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
309 function testOutputWNullChannelStringNLStringNLArbitraryAgain() {
310 $this->m
->output( "", null );
311 $this->m
->output( "foo", null );
312 $this->m
->output( "", null );
313 $this->m
->output( "\nb", null );
314 $this->m
->output( "a", null );
315 $this->m
->output( "", null );
316 $this->m
->output( "r\n", null );
317 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
320 function testOutputWChannelString() {
321 $this->m
->output( "foo", "bazChannel" );
322 $this->assertOutputPrePostShutdown( "foo", true );
325 function testOutputWChannelStringNL() {
326 $this->m
->output( "foo\n", "bazChannel" );
327 $this->assertOutputPrePostShutdown( "foo", true );
330 function testOutputWChannelStringNLNL() {
331 // If this test fails, note that output takes strings with double line
332 // endings (although output's implementation in this situation calls
333 // outputChanneled with a string ending in a nl ... which is not allowed
334 // according to the documentation of outputChanneled)
335 $this->m
->output( "foo\n\n", "bazChannel" );
336 $this->assertOutputPrePostShutdown( "foo\n", true );
339 function testOutputWChannelStringNLString() {
340 $this->m
->output( "foo\nbar", "bazChannel" );
341 $this->assertOutputPrePostShutdown( "foo\nbar", true );
344 function testOutputWChannelStringNLStringNL() {
345 $this->m
->output( "foo\nbar\n", "bazChannel" );
346 $this->assertOutputPrePostShutdown( "foo\nbar", true );
349 function testOutputWChannelStringNLStringNLLinewise() {
350 $this->m
->output( "foo\n", "bazChannel" );
351 $this->m
->output( "bar\n", "bazChannel" );
352 $this->assertOutputPrePostShutdown( "foobar", true );
355 function testOutputWChannelStringNLStringNLArbitrary() {
356 $this->m
->output( "", "bazChannel" );
357 $this->m
->output( "foo", "bazChannel" );
358 $this->m
->output( "", "bazChannel" );
359 $this->m
->output( "\n", "bazChannel" );
360 $this->m
->output( "ba", "bazChannel" );
361 $this->m
->output( "", "bazChannel" );
362 $this->m
->output( "r\n", "bazChannel" );
363 $this->assertOutputPrePostShutdown( "foobar", true );
366 function testOutputWChannelStringNLStringNLArbitraryAgain() {
367 $this->m
->output( "", "bazChannel" );
368 $this->m
->output( "foo", "bazChannel" );
369 $this->m
->output( "", "bazChannel" );
370 $this->m
->output( "\nb", "bazChannel" );
371 $this->m
->output( "a", "bazChannel" );
372 $this->m
->output( "", "bazChannel" );
373 $this->m
->output( "r\n", "bazChannel" );
374 $this->assertOutputPrePostShutdown( "foo\nbar", true );
377 function testOutputWMultipleChannelsChannelChange() {
378 $this->m
->output( "foo", "bazChannel" );
379 $this->m
->output( "bar", "bazChannel" );
380 $this->m
->output( "qux", "quuxChannel" );
381 $this->m
->output( "corge", "bazChannel" );
382 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
385 function testOutputWMultipleChannelsChannelChangeNL() {
386 $this->m
->output( "foo", "bazChannel" );
387 $this->m
->output( "bar\n", "bazChannel" );
388 $this->m
->output( "qux\n", "quuxChannel" );
389 $this->m
->output( "corge", "bazChannel" );
390 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
393 function testOutputWAndWOChannelStringStartWO() {
394 $this->m
->output( "foo" );
395 $this->m
->output( "bar", "bazChannel" );
396 $this->m
->output( "qux" );
397 $this->m
->output( "quux", "bazChannel" );
398 $this->assertOutputPrePostShutdown( "foobar\nquxquux", true );
401 function testOutputWAndWOChannelStringStartW() {
402 $this->m
->output( "foo", "bazChannel" );
403 $this->m
->output( "bar" );
404 $this->m
->output( "qux", "bazChannel" );
405 $this->m
->output( "quux" );
406 $this->assertOutputPrePostShutdown( "foo\nbarqux\nquux", false );
409 function testOutputWChannelTypeSwitch() {
410 $this->m
->output( "foo", 1 );
411 $this->m
->output( "bar", 1.0 );
412 $this->assertOutputPrePostShutdown( "foo\nbar", true );
415 function testOutputIntermittentEmpty() {
416 $this->m
->output( "foo" );
417 $this->m
->output( "" );
418 $this->m
->output( "bar" );
419 $this->assertOutputPrePostShutdown( "foobar", false );
422 function testOutputIntermittentFalse() {
423 $this->m
->output( "foo" );
424 $this->m
->output( false );
425 $this->m
->output( "bar" );
426 $this->assertOutputPrePostShutdown( "foobar", false );
429 function testOutputIntermittentFalseAfterOtherChannel() {
430 $this->m
->output( "qux", "quuxChannel" );
431 $this->m
->output( "foo" );
432 $this->m
->output( false );
433 $this->m
->output( "bar" );
434 $this->assertOutputPrePostShutdown( "qux\nfoobar", false );
437 function testOutputWNullChannelIntermittentEmpty() {
438 $this->m
->output( "foo", null );
439 $this->m
->output( "", null );
440 $this->m
->output( "bar", null );
441 $this->assertOutputPrePostShutdown( "foobar", false );
444 function testOutputWNullChannelIntermittentFalse() {
445 $this->m
->output( "foo", null );
446 $this->m
->output( false, null );
447 $this->m
->output( "bar", null );
448 $this->assertOutputPrePostShutdown( "foobar", false );
451 function testOutputWChannelIntermittentEmpty() {
452 $this->m
->output( "foo", "bazChannel" );
453 $this->m
->output( "", "bazChannel" );
454 $this->m
->output( "bar", "bazChannel" );
455 $this->assertOutputPrePostShutdown( "foobar", true );
458 function testOutputWChannelIntermittentFalse() {
459 $this->m
->output( "foo", "bazChannel" );
460 $this->m
->output( false, "bazChannel" );
461 $this->m
->output( "bar", "bazChannel" );
462 $this->assertOutputPrePostShutdown( "foobar", true );
465 // Note that (per documentation) outputChanneled does take strings that end
466 // in \n, hence we do not test such strings.
468 function testOutputChanneledEmpty() {
469 $this->m
->outputChanneled( "" );
470 $this->assertOutputPrePostShutdown( "\n", false );
473 function testOutputChanneledString() {
474 $this->m
->outputChanneled( "foo" );
475 $this->assertOutputPrePostShutdown( "foo\n", false );
478 function testOutputChanneledStringString() {
479 $this->m
->outputChanneled( "foo" );
480 $this->m
->outputChanneled( "bar" );
481 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
484 function testOutputChanneledStringNLString() {
485 $this->m
->outputChanneled( "foo\nbar" );
486 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
489 function testOutputChanneledStringNLStringNLArbitraryAgain() {
490 $this->m
->outputChanneled( "" );
491 $this->m
->outputChanneled( "foo" );
492 $this->m
->outputChanneled( "" );
493 $this->m
->outputChanneled( "\nb" );
494 $this->m
->outputChanneled( "a" );
495 $this->m
->outputChanneled( "" );
496 $this->m
->outputChanneled( "r" );
497 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
500 function testOutputChanneledWNullChannelEmpty() {
501 $this->m
->outputChanneled( "", null );
502 $this->assertOutputPrePostShutdown( "\n", false );
505 function testOutputChanneledWNullChannelString() {
506 $this->m
->outputChanneled( "foo", null );
507 $this->assertOutputPrePostShutdown( "foo\n", false );
510 function testOutputChanneledWNullChannelStringString() {
511 $this->m
->outputChanneled( "foo", null );
512 $this->m
->outputChanneled( "bar", null );
513 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
516 function testOutputChanneledWNullChannelStringNLString() {
517 $this->m
->outputChanneled( "foo\nbar", null );
518 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
521 function testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain() {
522 $this->m
->outputChanneled( "", null );
523 $this->m
->outputChanneled( "foo", null );
524 $this->m
->outputChanneled( "", null );
525 $this->m
->outputChanneled( "\nb", null );
526 $this->m
->outputChanneled( "a", null );
527 $this->m
->outputChanneled( "", null );
528 $this->m
->outputChanneled( "r", null );
529 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
532 function testOutputChanneledWChannelString() {
533 $this->m
->outputChanneled( "foo", "bazChannel" );
534 $this->assertOutputPrePostShutdown( "foo", true );
537 function testOutputChanneledWChannelStringNLString() {
538 $this->m
->outputChanneled( "foo\nbar", "bazChannel" );
539 $this->assertOutputPrePostShutdown( "foo\nbar", true );
542 function testOutputChanneledWChannelStringString() {
543 $this->m
->outputChanneled( "foo", "bazChannel" );
544 $this->m
->outputChanneled( "bar", "bazChannel" );
545 $this->assertOutputPrePostShutdown( "foobar", true );
548 function testOutputChanneledWChannelStringNLStringNLArbitraryAgain() {
549 $this->m
->outputChanneled( "", "bazChannel" );
550 $this->m
->outputChanneled( "foo", "bazChannel" );
551 $this->m
->outputChanneled( "", "bazChannel" );
552 $this->m
->outputChanneled( "\nb", "bazChannel" );
553 $this->m
->outputChanneled( "a", "bazChannel" );
554 $this->m
->outputChanneled( "", "bazChannel" );
555 $this->m
->outputChanneled( "r", "bazChannel" );
556 $this->assertOutputPrePostShutdown( "foo\nbar", true );
559 function testOutputChanneledWMultipleChannelsChannelChange() {
560 $this->m
->outputChanneled( "foo", "bazChannel" );
561 $this->m
->outputChanneled( "bar", "bazChannel" );
562 $this->m
->outputChanneled( "qux", "quuxChannel" );
563 $this->m
->outputChanneled( "corge", "bazChannel" );
564 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
567 function testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull() {
568 $this->m
->outputChanneled( "foo", "bazChannel" );
569 $this->m
->outputChanneled( "bar", null );
570 $this->m
->outputChanneled( "qux", null );
571 $this->m
->outputChanneled( "corge", "bazChannel" );
572 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
575 function testOutputChanneledWMultipleChannelsChannelAfterNullChange() {
576 $this->m
->outputChanneled( "foo", "bazChannel" );
577 $this->m
->outputChanneled( "bar", null );
578 $this->m
->outputChanneled( "qux", null );
579 $this->m
->outputChanneled( "corge", "quuxChannel" );
580 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
583 function testOutputChanneledWAndWOChannelStringStartWO() {
584 $this->m
->outputChanneled( "foo" );
585 $this->m
->outputChanneled( "bar", "bazChannel" );
586 $this->m
->outputChanneled( "qux" );
587 $this->m
->outputChanneled( "quux", "bazChannel" );
588 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux", true );
591 function testOutputChanneledWAndWOChannelStringStartW() {
592 $this->m
->outputChanneled( "foo", "bazChannel" );
593 $this->m
->outputChanneled( "bar" );
594 $this->m
->outputChanneled( "qux", "bazChannel" );
595 $this->m
->outputChanneled( "quux" );
596 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux\n", false );
599 function testOutputChanneledWChannelTypeSwitch() {
600 $this->m
->outputChanneled( "foo", 1 );
601 $this->m
->outputChanneled( "bar", 1.0 );
602 $this->assertOutputPrePostShutdown( "foo\nbar", true );
605 function testOutputChanneledWOChannelIntermittentEmpty() {
606 $this->m
->outputChanneled( "foo" );
607 $this->m
->outputChanneled( "" );
608 $this->m
->outputChanneled( "bar" );
609 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
612 function testOutputChanneledWOChannelIntermittentFalse() {
613 $this->m
->outputChanneled( "foo" );
614 $this->m
->outputChanneled( false );
615 $this->m
->outputChanneled( "bar" );
616 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
619 function testOutputChanneledWNullChannelIntermittentEmpty() {
620 $this->m
->outputChanneled( "foo", null );
621 $this->m
->outputChanneled( "", null );
622 $this->m
->outputChanneled( "bar", null );
623 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
626 function testOutputChanneledWNullChannelIntermittentFalse() {
627 $this->m
->outputChanneled( "foo", null );
628 $this->m
->outputChanneled( false, null );
629 $this->m
->outputChanneled( "bar", null );
630 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
633 function testOutputChanneledWChannelIntermittentEmpty() {
634 $this->m
->outputChanneled( "foo", "bazChannel" );
635 $this->m
->outputChanneled( "", "bazChannel" );
636 $this->m
->outputChanneled( "bar", "bazChannel" );
637 $this->assertOutputPrePostShutdown( "foobar", true );
640 function testOutputChanneledWChannelIntermittentFalse() {
641 $this->m
->outputChanneled( "foo", "bazChannel" );
642 $this->m
->outputChanneled( false, "bazChannel" );
643 $this->m
->outputChanneled( "bar", "bazChannel" );
644 $this->assertOutputPrePostShutdown( "foo\nbar", true );
647 function testCleanupChanneledClean() {
648 $this->m
->cleanupChanneled();
649 $this->assertOutputPrePostShutdown( "", false );
652 function testCleanupChanneledAfterOutput() {
653 $this->m
->output( "foo" );
654 $this->m
->cleanupChanneled();
655 $this->assertOutputPrePostShutdown( "foo", false );
658 function testCleanupChanneledAfterOutputWNullChannel() {
659 $this->m
->output( "foo", null );
660 $this->m
->cleanupChanneled();
661 $this->assertOutputPrePostShutdown( "foo", false );
664 function testCleanupChanneledAfterOutputWChannel() {
665 $this->m
->output( "foo", "bazChannel" );
666 $this->m
->cleanupChanneled();
667 $this->assertOutputPrePostShutdown( "foo\n", false );
670 function testCleanupChanneledAfterNLOutput() {
671 $this->m
->output( "foo\n" );
672 $this->m
->cleanupChanneled();
673 $this->assertOutputPrePostShutdown( "foo\n", false );
676 function testCleanupChanneledAfterNLOutputWNullChannel() {
677 $this->m
->output( "foo\n", null );
678 $this->m
->cleanupChanneled();
679 $this->assertOutputPrePostShutdown( "foo\n", false );
682 function testCleanupChanneledAfterNLOutputWChannel() {
683 $this->m
->output( "foo\n", "bazChannel" );
684 $this->m
->cleanupChanneled();
685 $this->assertOutputPrePostShutdown( "foo\n", false );
688 function testCleanupChanneledAfterOutputChanneledWOChannel() {
689 $this->m
->outputChanneled( "foo" );
690 $this->m
->cleanupChanneled();
691 $this->assertOutputPrePostShutdown( "foo\n", false );
694 function testCleanupChanneledAfterOutputChanneledWNullChannel() {
695 $this->m
->outputChanneled( "foo", null );
696 $this->m
->cleanupChanneled();
697 $this->assertOutputPrePostShutdown( "foo\n", false );
700 function testCleanupChanneledAfterOutputChanneledWChannel() {
701 $this->m
->outputChanneled( "foo", "bazChannel" );
702 $this->m
->cleanupChanneled();
703 $this->assertOutputPrePostShutdown( "foo\n", false );
706 function testMultipleMaintenanceObjectsInteractionOutput() {
707 $m2 = new MaintenanceFixup( $this );
709 $this->m
->output( "foo" );
710 $m2->output( "bar" );
712 $this->assertEquals( "foobar", $this->getActualOutput(),
713 "Output before shutdown simulation (m2)" );
714 $m2->simulateShutdown();
715 $this->assertOutputPrePostShutdown( "foobar", false );
718 function testMultipleMaintenanceObjectsInteractionOutputWNullChannel() {
719 $m2 = new MaintenanceFixup( $this );
721 $this->m
->output( "foo", null );
722 $m2->output( "bar", null );
724 $this->assertEquals( "foobar", $this->getActualOutput(),
725 "Output before shutdown simulation (m2)" );
726 $m2->simulateShutdown();
727 $this->assertOutputPrePostShutdown( "foobar", false );
730 function testMultipleMaintenanceObjectsInteractionOutputWChannel() {
731 $m2 = new MaintenanceFixup( $this );
733 $this->m
->output( "foo", "bazChannel" );
734 $m2->output( "bar", "bazChannel" );
736 $this->assertEquals( "foobar", $this->getActualOutput(),
737 "Output before shutdown simulation (m2)" );
738 $m2->simulateShutdown();
739 $this->assertOutputPrePostShutdown( "foobar\n", true );
742 function testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL() {
743 $m2 = new MaintenanceFixup( $this );
745 $this->m
->output( "foo\n", null );
746 $m2->output( "bar\n", null );
748 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
749 "Output before shutdown simulation (m2)" );
750 $m2->simulateShutdown();
751 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
754 function testMultipleMaintenanceObjectsInteractionOutputWChannelNL() {
755 $m2 = new MaintenanceFixup( $this );
757 $this->m
->output( "foo\n", "bazChannel" );
758 $m2->output( "bar\n", "bazChannel" );
760 $this->assertEquals( "foobar", $this->getActualOutput(),
761 "Output before shutdown simulation (m2)" );
762 $m2->simulateShutdown();
763 $this->assertOutputPrePostShutdown( "foobar\n", true );
766 function testMultipleMaintenanceObjectsInteractionOutputChanneled() {
767 $m2 = new MaintenanceFixup( $this );
769 $this->m
->outputChanneled( "foo" );
770 $m2->outputChanneled( "bar" );
772 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
773 "Output before shutdown simulation (m2)" );
774 $m2->simulateShutdown();
775 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
778 function testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel() {
779 $m2 = new MaintenanceFixup( $this );
781 $this->m
->outputChanneled( "foo", null );
782 $m2->outputChanneled( "bar", null );
784 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
785 "Output before shutdown simulation (m2)" );
786 $m2->simulateShutdown();
787 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
790 function testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel() {
791 $m2 = new MaintenanceFixup( $this );
793 $this->m
->outputChanneled( "foo", "bazChannel" );
794 $m2->outputChanneled( "bar", "bazChannel" );
796 $this->assertEquals( "foobar", $this->getActualOutput(),
797 "Output before shutdown simulation (m2)" );
798 $m2->simulateShutdown();
799 $this->assertOutputPrePostShutdown( "foobar\n", true );
802 function testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel() {
803 $m2 = new MaintenanceFixup( $this );
805 $this->m
->outputChanneled( "foo", "bazChannel" );
806 $m2->outputChanneled( "bar", "bazChannel" );
808 $this->assertEquals( "foobar", $this->getActualOutput(),
809 "Output before first cleanup" );
810 $this->m
->cleanupChanneled();
811 $this->assertEquals( "foobar\n", $this->getActualOutput(),
812 "Output after first cleanup" );
813 $m2->cleanupChanneled();
814 $this->assertEquals( "foobar\n\n", $this->getActualOutput(),
815 "Output after second cleanup" );
817 $m2->simulateShutdown();
818 $this->assertOutputPrePostShutdown( "foobar\n\n", false );