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 if 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 behavior. 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;
115 // --- Making protected functions visible for test
117 public function output( $out, $channel = null ) {
118 // Just to make PHP not nag about signature mismatches, we copied
119 // Maintenance::output signature. However, we do not use (or rely on)
120 // those variables. Instead we pass to Maintenance::output whatever we
121 // receive at runtime.
122 return call_user_func_array( array( "parent", __FUNCTION__
), func_get_args() );
126 // --- Requirements for getting instance of abstract class
128 public function execute() {
129 $this->testCase
->fail( __METHOD__
. " called unexpectedly" );
134 * @covers Maintenance
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 behavior, but rather currently existing behavior.
191 function testOutputEmpty() {
192 $this->m
->output( "" );
193 $this->assertOutputPrePostShutdown( "", false );
196 function testOutputString() {
197 $this->m
->output( "foo" );
198 $this->assertOutputPrePostShutdown( "foo", false );
201 function testOutputStringString() {
202 $this->m
->output( "foo" );
203 $this->m
->output( "bar" );
204 $this->assertOutputPrePostShutdown( "foobar", false );
207 function testOutputStringNL() {
208 $this->m
->output( "foo\n" );
209 $this->assertOutputPrePostShutdown( "foo\n", false );
212 function testOutputStringNLNL() {
213 $this->m
->output( "foo\n\n" );
214 $this->assertOutputPrePostShutdown( "foo\n\n", false );
217 function testOutputStringNLString() {
218 $this->m
->output( "foo\nbar" );
219 $this->assertOutputPrePostShutdown( "foo\nbar", false );
222 function testOutputStringNLStringNL() {
223 $this->m
->output( "foo\nbar\n" );
224 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
227 function testOutputStringNLStringNLLinewise() {
228 $this->m
->output( "foo\n" );
229 $this->m
->output( "bar\n" );
230 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
233 function testOutputStringNLStringNLArbitrary() {
234 $this->m
->output( "" );
235 $this->m
->output( "foo" );
236 $this->m
->output( "" );
237 $this->m
->output( "\n" );
238 $this->m
->output( "ba" );
239 $this->m
->output( "" );
240 $this->m
->output( "r\n" );
241 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
244 function testOutputStringNLStringNLArbitraryAgain() {
245 $this->m
->output( "" );
246 $this->m
->output( "foo" );
247 $this->m
->output( "" );
248 $this->m
->output( "\nb" );
249 $this->m
->output( "a" );
250 $this->m
->output( "" );
251 $this->m
->output( "r\n" );
252 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
255 function testOutputWNullChannelEmpty() {
256 $this->m
->output( "", null );
257 $this->assertOutputPrePostShutdown( "", false );
260 function testOutputWNullChannelString() {
261 $this->m
->output( "foo", null );
262 $this->assertOutputPrePostShutdown( "foo", false );
265 function testOutputWNullChannelStringString() {
266 $this->m
->output( "foo", null );
267 $this->m
->output( "bar", null );
268 $this->assertOutputPrePostShutdown( "foobar", false );
271 function testOutputWNullChannelStringNL() {
272 $this->m
->output( "foo\n", null );
273 $this->assertOutputPrePostShutdown( "foo\n", false );
276 function testOutputWNullChannelStringNLNL() {
277 $this->m
->output( "foo\n\n", null );
278 $this->assertOutputPrePostShutdown( "foo\n\n", false );
281 function testOutputWNullChannelStringNLString() {
282 $this->m
->output( "foo\nbar", null );
283 $this->assertOutputPrePostShutdown( "foo\nbar", false );
286 function testOutputWNullChannelStringNLStringNL() {
287 $this->m
->output( "foo\nbar\n", null );
288 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
291 function testOutputWNullChannelStringNLStringNLLinewise() {
292 $this->m
->output( "foo\n", null );
293 $this->m
->output( "bar\n", null );
294 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
297 function testOutputWNullChannelStringNLStringNLArbitrary() {
298 $this->m
->output( "", null );
299 $this->m
->output( "foo", null );
300 $this->m
->output( "", null );
301 $this->m
->output( "\n", null );
302 $this->m
->output( "ba", null );
303 $this->m
->output( "", null );
304 $this->m
->output( "r\n", null );
305 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
308 function testOutputWNullChannelStringNLStringNLArbitraryAgain() {
309 $this->m
->output( "", null );
310 $this->m
->output( "foo", null );
311 $this->m
->output( "", null );
312 $this->m
->output( "\nb", null );
313 $this->m
->output( "a", null );
314 $this->m
->output( "", null );
315 $this->m
->output( "r\n", null );
316 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
319 function testOutputWChannelString() {
320 $this->m
->output( "foo", "bazChannel" );
321 $this->assertOutputPrePostShutdown( "foo", true );
324 function testOutputWChannelStringNL() {
325 $this->m
->output( "foo\n", "bazChannel" );
326 $this->assertOutputPrePostShutdown( "foo", true );
329 function testOutputWChannelStringNLNL() {
330 // If this test fails, note that output takes strings with double line
331 // endings (although output's implementation in this situation calls
332 // outputChanneled with a string ending in a nl ... which is not allowed
333 // according to the documentation of outputChanneled)
334 $this->m
->output( "foo\n\n", "bazChannel" );
335 $this->assertOutputPrePostShutdown( "foo\n", true );
338 function testOutputWChannelStringNLString() {
339 $this->m
->output( "foo\nbar", "bazChannel" );
340 $this->assertOutputPrePostShutdown( "foo\nbar", true );
343 function testOutputWChannelStringNLStringNL() {
344 $this->m
->output( "foo\nbar\n", "bazChannel" );
345 $this->assertOutputPrePostShutdown( "foo\nbar", true );
348 function testOutputWChannelStringNLStringNLLinewise() {
349 $this->m
->output( "foo\n", "bazChannel" );
350 $this->m
->output( "bar\n", "bazChannel" );
351 $this->assertOutputPrePostShutdown( "foobar", true );
354 function testOutputWChannelStringNLStringNLArbitrary() {
355 $this->m
->output( "", "bazChannel" );
356 $this->m
->output( "foo", "bazChannel" );
357 $this->m
->output( "", "bazChannel" );
358 $this->m
->output( "\n", "bazChannel" );
359 $this->m
->output( "ba", "bazChannel" );
360 $this->m
->output( "", "bazChannel" );
361 $this->m
->output( "r\n", "bazChannel" );
362 $this->assertOutputPrePostShutdown( "foobar", true );
365 function testOutputWChannelStringNLStringNLArbitraryAgain() {
366 $this->m
->output( "", "bazChannel" );
367 $this->m
->output( "foo", "bazChannel" );
368 $this->m
->output( "", "bazChannel" );
369 $this->m
->output( "\nb", "bazChannel" );
370 $this->m
->output( "a", "bazChannel" );
371 $this->m
->output( "", "bazChannel" );
372 $this->m
->output( "r\n", "bazChannel" );
373 $this->assertOutputPrePostShutdown( "foo\nbar", true );
376 function testOutputWMultipleChannelsChannelChange() {
377 $this->m
->output( "foo", "bazChannel" );
378 $this->m
->output( "bar", "bazChannel" );
379 $this->m
->output( "qux", "quuxChannel" );
380 $this->m
->output( "corge", "bazChannel" );
381 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
384 function testOutputWMultipleChannelsChannelChangeNL() {
385 $this->m
->output( "foo", "bazChannel" );
386 $this->m
->output( "bar\n", "bazChannel" );
387 $this->m
->output( "qux\n", "quuxChannel" );
388 $this->m
->output( "corge", "bazChannel" );
389 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
392 function testOutputWAndWOChannelStringStartWO() {
393 $this->m
->output( "foo" );
394 $this->m
->output( "bar", "bazChannel" );
395 $this->m
->output( "qux" );
396 $this->m
->output( "quux", "bazChannel" );
397 $this->assertOutputPrePostShutdown( "foobar\nquxquux", true );
400 function testOutputWAndWOChannelStringStartW() {
401 $this->m
->output( "foo", "bazChannel" );
402 $this->m
->output( "bar" );
403 $this->m
->output( "qux", "bazChannel" );
404 $this->m
->output( "quux" );
405 $this->assertOutputPrePostShutdown( "foo\nbarqux\nquux", false );
408 function testOutputWChannelTypeSwitch() {
409 $this->m
->output( "foo", 1 );
410 $this->m
->output( "bar", 1.0 );
411 $this->assertOutputPrePostShutdown( "foo\nbar", true );
414 function testOutputIntermittentEmpty() {
415 $this->m
->output( "foo" );
416 $this->m
->output( "" );
417 $this->m
->output( "bar" );
418 $this->assertOutputPrePostShutdown( "foobar", false );
421 function testOutputIntermittentFalse() {
422 $this->m
->output( "foo" );
423 $this->m
->output( false );
424 $this->m
->output( "bar" );
425 $this->assertOutputPrePostShutdown( "foobar", false );
428 function testOutputIntermittentFalseAfterOtherChannel() {
429 $this->m
->output( "qux", "quuxChannel" );
430 $this->m
->output( "foo" );
431 $this->m
->output( false );
432 $this->m
->output( "bar" );
433 $this->assertOutputPrePostShutdown( "qux\nfoobar", false );
436 function testOutputWNullChannelIntermittentEmpty() {
437 $this->m
->output( "foo", null );
438 $this->m
->output( "", null );
439 $this->m
->output( "bar", null );
440 $this->assertOutputPrePostShutdown( "foobar", false );
443 function testOutputWNullChannelIntermittentFalse() {
444 $this->m
->output( "foo", null );
445 $this->m
->output( false, null );
446 $this->m
->output( "bar", null );
447 $this->assertOutputPrePostShutdown( "foobar", false );
450 function testOutputWChannelIntermittentEmpty() {
451 $this->m
->output( "foo", "bazChannel" );
452 $this->m
->output( "", "bazChannel" );
453 $this->m
->output( "bar", "bazChannel" );
454 $this->assertOutputPrePostShutdown( "foobar", true );
457 function testOutputWChannelIntermittentFalse() {
458 $this->m
->output( "foo", "bazChannel" );
459 $this->m
->output( false, "bazChannel" );
460 $this->m
->output( "bar", "bazChannel" );
461 $this->assertOutputPrePostShutdown( "foobar", true );
464 // Note that (per documentation) outputChanneled does take strings that end
465 // in \n, hence we do not test such strings.
467 function testOutputChanneledEmpty() {
468 $this->m
->outputChanneled( "" );
469 $this->assertOutputPrePostShutdown( "\n", false );
472 function testOutputChanneledString() {
473 $this->m
->outputChanneled( "foo" );
474 $this->assertOutputPrePostShutdown( "foo\n", false );
477 function testOutputChanneledStringString() {
478 $this->m
->outputChanneled( "foo" );
479 $this->m
->outputChanneled( "bar" );
480 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
483 function testOutputChanneledStringNLString() {
484 $this->m
->outputChanneled( "foo\nbar" );
485 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
488 function testOutputChanneledStringNLStringNLArbitraryAgain() {
489 $this->m
->outputChanneled( "" );
490 $this->m
->outputChanneled( "foo" );
491 $this->m
->outputChanneled( "" );
492 $this->m
->outputChanneled( "\nb" );
493 $this->m
->outputChanneled( "a" );
494 $this->m
->outputChanneled( "" );
495 $this->m
->outputChanneled( "r" );
496 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
499 function testOutputChanneledWNullChannelEmpty() {
500 $this->m
->outputChanneled( "", null );
501 $this->assertOutputPrePostShutdown( "\n", false );
504 function testOutputChanneledWNullChannelString() {
505 $this->m
->outputChanneled( "foo", null );
506 $this->assertOutputPrePostShutdown( "foo\n", false );
509 function testOutputChanneledWNullChannelStringString() {
510 $this->m
->outputChanneled( "foo", null );
511 $this->m
->outputChanneled( "bar", null );
512 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
515 function testOutputChanneledWNullChannelStringNLString() {
516 $this->m
->outputChanneled( "foo\nbar", null );
517 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
520 function testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain() {
521 $this->m
->outputChanneled( "", null );
522 $this->m
->outputChanneled( "foo", null );
523 $this->m
->outputChanneled( "", null );
524 $this->m
->outputChanneled( "\nb", null );
525 $this->m
->outputChanneled( "a", null );
526 $this->m
->outputChanneled( "", null );
527 $this->m
->outputChanneled( "r", null );
528 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
531 function testOutputChanneledWChannelString() {
532 $this->m
->outputChanneled( "foo", "bazChannel" );
533 $this->assertOutputPrePostShutdown( "foo", true );
536 function testOutputChanneledWChannelStringNLString() {
537 $this->m
->outputChanneled( "foo\nbar", "bazChannel" );
538 $this->assertOutputPrePostShutdown( "foo\nbar", true );
541 function testOutputChanneledWChannelStringString() {
542 $this->m
->outputChanneled( "foo", "bazChannel" );
543 $this->m
->outputChanneled( "bar", "bazChannel" );
544 $this->assertOutputPrePostShutdown( "foobar", true );
547 function testOutputChanneledWChannelStringNLStringNLArbitraryAgain() {
548 $this->m
->outputChanneled( "", "bazChannel" );
549 $this->m
->outputChanneled( "foo", "bazChannel" );
550 $this->m
->outputChanneled( "", "bazChannel" );
551 $this->m
->outputChanneled( "\nb", "bazChannel" );
552 $this->m
->outputChanneled( "a", "bazChannel" );
553 $this->m
->outputChanneled( "", "bazChannel" );
554 $this->m
->outputChanneled( "r", "bazChannel" );
555 $this->assertOutputPrePostShutdown( "foo\nbar", true );
558 function testOutputChanneledWMultipleChannelsChannelChange() {
559 $this->m
->outputChanneled( "foo", "bazChannel" );
560 $this->m
->outputChanneled( "bar", "bazChannel" );
561 $this->m
->outputChanneled( "qux", "quuxChannel" );
562 $this->m
->outputChanneled( "corge", "bazChannel" );
563 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
566 function testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull() {
567 $this->m
->outputChanneled( "foo", "bazChannel" );
568 $this->m
->outputChanneled( "bar", null );
569 $this->m
->outputChanneled( "qux", null );
570 $this->m
->outputChanneled( "corge", "bazChannel" );
571 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
574 function testOutputChanneledWMultipleChannelsChannelAfterNullChange() {
575 $this->m
->outputChanneled( "foo", "bazChannel" );
576 $this->m
->outputChanneled( "bar", null );
577 $this->m
->outputChanneled( "qux", null );
578 $this->m
->outputChanneled( "corge", "quuxChannel" );
579 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
582 function testOutputChanneledWAndWOChannelStringStartWO() {
583 $this->m
->outputChanneled( "foo" );
584 $this->m
->outputChanneled( "bar", "bazChannel" );
585 $this->m
->outputChanneled( "qux" );
586 $this->m
->outputChanneled( "quux", "bazChannel" );
587 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux", true );
590 function testOutputChanneledWAndWOChannelStringStartW() {
591 $this->m
->outputChanneled( "foo", "bazChannel" );
592 $this->m
->outputChanneled( "bar" );
593 $this->m
->outputChanneled( "qux", "bazChannel" );
594 $this->m
->outputChanneled( "quux" );
595 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux\n", false );
598 function testOutputChanneledWChannelTypeSwitch() {
599 $this->m
->outputChanneled( "foo", 1 );
600 $this->m
->outputChanneled( "bar", 1.0 );
601 $this->assertOutputPrePostShutdown( "foo\nbar", true );
604 function testOutputChanneledWOChannelIntermittentEmpty() {
605 $this->m
->outputChanneled( "foo" );
606 $this->m
->outputChanneled( "" );
607 $this->m
->outputChanneled( "bar" );
608 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
611 function testOutputChanneledWOChannelIntermittentFalse() {
612 $this->m
->outputChanneled( "foo" );
613 $this->m
->outputChanneled( false );
614 $this->m
->outputChanneled( "bar" );
615 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
618 function testOutputChanneledWNullChannelIntermittentEmpty() {
619 $this->m
->outputChanneled( "foo", null );
620 $this->m
->outputChanneled( "", null );
621 $this->m
->outputChanneled( "bar", null );
622 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
625 function testOutputChanneledWNullChannelIntermittentFalse() {
626 $this->m
->outputChanneled( "foo", null );
627 $this->m
->outputChanneled( false, null );
628 $this->m
->outputChanneled( "bar", null );
629 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
632 function testOutputChanneledWChannelIntermittentEmpty() {
633 $this->m
->outputChanneled( "foo", "bazChannel" );
634 $this->m
->outputChanneled( "", "bazChannel" );
635 $this->m
->outputChanneled( "bar", "bazChannel" );
636 $this->assertOutputPrePostShutdown( "foobar", true );
639 function testOutputChanneledWChannelIntermittentFalse() {
640 $this->m
->outputChanneled( "foo", "bazChannel" );
641 $this->m
->outputChanneled( false, "bazChannel" );
642 $this->m
->outputChanneled( "bar", "bazChannel" );
643 $this->assertOutputPrePostShutdown( "foo\nbar", true );
646 function testCleanupChanneledClean() {
647 $this->m
->cleanupChanneled();
648 $this->assertOutputPrePostShutdown( "", false );
651 function testCleanupChanneledAfterOutput() {
652 $this->m
->output( "foo" );
653 $this->m
->cleanupChanneled();
654 $this->assertOutputPrePostShutdown( "foo", false );
657 function testCleanupChanneledAfterOutputWNullChannel() {
658 $this->m
->output( "foo", null );
659 $this->m
->cleanupChanneled();
660 $this->assertOutputPrePostShutdown( "foo", false );
663 function testCleanupChanneledAfterOutputWChannel() {
664 $this->m
->output( "foo", "bazChannel" );
665 $this->m
->cleanupChanneled();
666 $this->assertOutputPrePostShutdown( "foo\n", false );
669 function testCleanupChanneledAfterNLOutput() {
670 $this->m
->output( "foo\n" );
671 $this->m
->cleanupChanneled();
672 $this->assertOutputPrePostShutdown( "foo\n", false );
675 function testCleanupChanneledAfterNLOutputWNullChannel() {
676 $this->m
->output( "foo\n", null );
677 $this->m
->cleanupChanneled();
678 $this->assertOutputPrePostShutdown( "foo\n", false );
681 function testCleanupChanneledAfterNLOutputWChannel() {
682 $this->m
->output( "foo\n", "bazChannel" );
683 $this->m
->cleanupChanneled();
684 $this->assertOutputPrePostShutdown( "foo\n", false );
687 function testCleanupChanneledAfterOutputChanneledWOChannel() {
688 $this->m
->outputChanneled( "foo" );
689 $this->m
->cleanupChanneled();
690 $this->assertOutputPrePostShutdown( "foo\n", false );
693 function testCleanupChanneledAfterOutputChanneledWNullChannel() {
694 $this->m
->outputChanneled( "foo", null );
695 $this->m
->cleanupChanneled();
696 $this->assertOutputPrePostShutdown( "foo\n", false );
699 function testCleanupChanneledAfterOutputChanneledWChannel() {
700 $this->m
->outputChanneled( "foo", "bazChannel" );
701 $this->m
->cleanupChanneled();
702 $this->assertOutputPrePostShutdown( "foo\n", false );
705 function testMultipleMaintenanceObjectsInteractionOutput() {
706 $m2 = new MaintenanceFixup( $this );
708 $this->m
->output( "foo" );
709 $m2->output( "bar" );
711 $this->assertEquals( "foobar", $this->getActualOutput(),
712 "Output before shutdown simulation (m2)" );
713 $m2->simulateShutdown();
714 $this->assertOutputPrePostShutdown( "foobar", false );
717 function testMultipleMaintenanceObjectsInteractionOutputWNullChannel() {
718 $m2 = new MaintenanceFixup( $this );
720 $this->m
->output( "foo", null );
721 $m2->output( "bar", null );
723 $this->assertEquals( "foobar", $this->getActualOutput(),
724 "Output before shutdown simulation (m2)" );
725 $m2->simulateShutdown();
726 $this->assertOutputPrePostShutdown( "foobar", false );
729 function testMultipleMaintenanceObjectsInteractionOutputWChannel() {
730 $m2 = new MaintenanceFixup( $this );
732 $this->m
->output( "foo", "bazChannel" );
733 $m2->output( "bar", "bazChannel" );
735 $this->assertEquals( "foobar", $this->getActualOutput(),
736 "Output before shutdown simulation (m2)" );
737 $m2->simulateShutdown();
738 $this->assertOutputPrePostShutdown( "foobar\n", true );
741 function testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL() {
742 $m2 = new MaintenanceFixup( $this );
744 $this->m
->output( "foo\n", null );
745 $m2->output( "bar\n", null );
747 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
748 "Output before shutdown simulation (m2)" );
749 $m2->simulateShutdown();
750 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
753 function testMultipleMaintenanceObjectsInteractionOutputWChannelNL() {
754 $m2 = new MaintenanceFixup( $this );
756 $this->m
->output( "foo\n", "bazChannel" );
757 $m2->output( "bar\n", "bazChannel" );
759 $this->assertEquals( "foobar", $this->getActualOutput(),
760 "Output before shutdown simulation (m2)" );
761 $m2->simulateShutdown();
762 $this->assertOutputPrePostShutdown( "foobar\n", true );
765 function testMultipleMaintenanceObjectsInteractionOutputChanneled() {
766 $m2 = new MaintenanceFixup( $this );
768 $this->m
->outputChanneled( "foo" );
769 $m2->outputChanneled( "bar" );
771 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
772 "Output before shutdown simulation (m2)" );
773 $m2->simulateShutdown();
774 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
777 function testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel() {
778 $m2 = new MaintenanceFixup( $this );
780 $this->m
->outputChanneled( "foo", null );
781 $m2->outputChanneled( "bar", null );
783 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
784 "Output before shutdown simulation (m2)" );
785 $m2->simulateShutdown();
786 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
789 function testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel() {
790 $m2 = new MaintenanceFixup( $this );
792 $this->m
->outputChanneled( "foo", "bazChannel" );
793 $m2->outputChanneled( "bar", "bazChannel" );
795 $this->assertEquals( "foobar", $this->getActualOutput(),
796 "Output before shutdown simulation (m2)" );
797 $m2->simulateShutdown();
798 $this->assertOutputPrePostShutdown( "foobar\n", true );
801 function testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel() {
802 $m2 = new MaintenanceFixup( $this );
804 $this->m
->outputChanneled( "foo", "bazChannel" );
805 $m2->outputChanneled( "bar", "bazChannel" );
807 $this->assertEquals( "foobar", $this->getActualOutput(),
808 "Output before first cleanup" );
809 $this->m
->cleanupChanneled();
810 $this->assertEquals( "foobar\n", $this->getActualOutput(),
811 "Output after first cleanup" );
812 $m2->cleanupChanneled();
813 $this->assertEquals( "foobar\n\n", $this->getActualOutput(),
814 "Output after second cleanup" );
816 $m2->simulateShutdown();
817 $this->assertOutputPrePostShutdown( "foobar\n\n", false );