test: coverage recording now needs to be explicit
[mediawiki.git] / tests / phpunit / maintenance / MaintenanceTest.php
blobf4b61afc2a018f61d7977139533b950bb890623b
1 <?php
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
6 // Maintenance.php
7 //
8 // For the same reason, we cannot just use FakeMaintenance.
10 /**
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
22 * Maintenance.
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
26 * ends.
29 class MaintenanceFixup extends Maintenance {
31 // --- Making up for the register_shutdown_function hack in Maintenance.php
33 /**
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
38 * simulation.
39 * But as it is already available, we also usi it to flagging tests as failed
41 * @var MediaWikiTestCase
43 private $testCase;
45 /**
46 * shutdownSimulated === true iff simulateShutdown has done it's work
48 * @var bool
50 private $shutdownSimulated = false;
52 /**
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
80 // it)
81 return;
84 return call_user_func_array( array( "parent", __FUNCTION__ ), func_get_args() );
87 /**
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" );
133 class MaintenanceTest extends MediaWikiTestCase {
137 * The main Maintenance instance that is used for testing.
139 * @var MaintenanceFixup
141 private $m;
144 protected function setUp() {
145 parent::setUp();
146 $this->m = new MaintenanceFixup( $this );
149 protected function tearDown() {
150 if ( $this->m ) {
151 $this->m->simulateShutdown();
152 $this->m = null;
154 parent::tearDown();
159 * asserts the output before and after simulating shutdown
161 * This function simulates shutdown of self::m.
163 * @param $preShutdownOutput string: expected output before simulating shutdown
164 * @param $expectNLAppending bool: Whether or not shutdown simulation is expected
165 * to add a newline to the output. If false, $preShutdownOutput is the
166 * expected output after shutdown simulation. Otherwise,
167 * $preShutdownOutput with an appended newline is the expected output
168 * after shutdown simulation.
170 private function assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending ) {
172 $this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
173 "Output before shutdown simulation" );
175 $this->m->simulateShutdown();
176 $this->m = null;
178 $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ? "\n" : "" );
179 $this->expectOutputString( $postShutdownOutput );
183 // Although the following tests do not seem to be too consistent (compare for
184 // example the newlines within the test.*StringString tests, or the
185 // test.*Intermittent.* tests), the objective of these tests is not to describe
186 // consistent behavior, but rather currently existing behavior.
188 function testOutputEmpty() {
189 $this->m->output( "" );
190 $this->assertOutputPrePostShutdown( "", false );
193 function testOutputString() {
194 $this->m->output( "foo" );
195 $this->assertOutputPrePostShutdown( "foo", false );
198 function testOutputStringString() {
199 $this->m->output( "foo" );
200 $this->m->output( "bar" );
201 $this->assertOutputPrePostShutdown( "foobar", false );
204 function testOutputStringNL() {
205 $this->m->output( "foo\n" );
206 $this->assertOutputPrePostShutdown( "foo\n", false );
209 function testOutputStringNLNL() {
210 $this->m->output( "foo\n\n" );
211 $this->assertOutputPrePostShutdown( "foo\n\n", false );
214 function testOutputStringNLString() {
215 $this->m->output( "foo\nbar" );
216 $this->assertOutputPrePostShutdown( "foo\nbar", false );
219 function testOutputStringNLStringNL() {
220 $this->m->output( "foo\nbar\n" );
221 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
224 function testOutputStringNLStringNLLinewise() {
225 $this->m->output( "foo\n" );
226 $this->m->output( "bar\n" );
227 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
230 function testOutputStringNLStringNLArbitrary() {
231 $this->m->output( "" );
232 $this->m->output( "foo" );
233 $this->m->output( "" );
234 $this->m->output( "\n" );
235 $this->m->output( "ba" );
236 $this->m->output( "" );
237 $this->m->output( "r\n" );
238 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
241 function testOutputStringNLStringNLArbitraryAgain() {
242 $this->m->output( "" );
243 $this->m->output( "foo" );
244 $this->m->output( "" );
245 $this->m->output( "\nb" );
246 $this->m->output( "a" );
247 $this->m->output( "" );
248 $this->m->output( "r\n" );
249 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
252 function testOutputWNullChannelEmpty() {
253 $this->m->output( "", null );
254 $this->assertOutputPrePostShutdown( "", false );
257 function testOutputWNullChannelString() {
258 $this->m->output( "foo", null );
259 $this->assertOutputPrePostShutdown( "foo", false );
262 function testOutputWNullChannelStringString() {
263 $this->m->output( "foo", null );
264 $this->m->output( "bar", null );
265 $this->assertOutputPrePostShutdown( "foobar", false );
268 function testOutputWNullChannelStringNL() {
269 $this->m->output( "foo\n", null );
270 $this->assertOutputPrePostShutdown( "foo\n", false );
273 function testOutputWNullChannelStringNLNL() {
274 $this->m->output( "foo\n\n", null );
275 $this->assertOutputPrePostShutdown( "foo\n\n", false );
278 function testOutputWNullChannelStringNLString() {
279 $this->m->output( "foo\nbar", null );
280 $this->assertOutputPrePostShutdown( "foo\nbar", false );
283 function testOutputWNullChannelStringNLStringNL() {
284 $this->m->output( "foo\nbar\n", null );
285 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
288 function testOutputWNullChannelStringNLStringNLLinewise() {
289 $this->m->output( "foo\n", null );
290 $this->m->output( "bar\n", null );
291 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
294 function testOutputWNullChannelStringNLStringNLArbitrary() {
295 $this->m->output( "", null );
296 $this->m->output( "foo", null );
297 $this->m->output( "", null );
298 $this->m->output( "\n", null );
299 $this->m->output( "ba", null );
300 $this->m->output( "", null );
301 $this->m->output( "r\n", null );
302 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
305 function testOutputWNullChannelStringNLStringNLArbitraryAgain() {
306 $this->m->output( "", null );
307 $this->m->output( "foo", null );
308 $this->m->output( "", null );
309 $this->m->output( "\nb", null );
310 $this->m->output( "a", null );
311 $this->m->output( "", null );
312 $this->m->output( "r\n", null );
313 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
316 function testOutputWChannelString() {
317 $this->m->output( "foo", "bazChannel" );
318 $this->assertOutputPrePostShutdown( "foo", true );
321 function testOutputWChannelStringNL() {
322 $this->m->output( "foo\n", "bazChannel" );
323 $this->assertOutputPrePostShutdown( "foo", true );
326 function testOutputWChannelStringNLNL() {
327 // If this test fails, note that output takes strings with double line
328 // endings (although output's implementation in this situation calls
329 // outputChanneled with a string ending in a nl ... which is not allowed
330 // according to the documentation of outputChanneled)
331 $this->m->output( "foo\n\n", "bazChannel" );
332 $this->assertOutputPrePostShutdown( "foo\n", true );
335 function testOutputWChannelStringNLString() {
336 $this->m->output( "foo\nbar", "bazChannel" );
337 $this->assertOutputPrePostShutdown( "foo\nbar", true );
340 function testOutputWChannelStringNLStringNL() {
341 $this->m->output( "foo\nbar\n", "bazChannel" );
342 $this->assertOutputPrePostShutdown( "foo\nbar", true );
345 function testOutputWChannelStringNLStringNLLinewise() {
346 $this->m->output( "foo\n", "bazChannel" );
347 $this->m->output( "bar\n", "bazChannel" );
348 $this->assertOutputPrePostShutdown( "foobar", true );
351 function testOutputWChannelStringNLStringNLArbitrary() {
352 $this->m->output( "", "bazChannel" );
353 $this->m->output( "foo", "bazChannel" );
354 $this->m->output( "", "bazChannel" );
355 $this->m->output( "\n", "bazChannel" );
356 $this->m->output( "ba", "bazChannel" );
357 $this->m->output( "", "bazChannel" );
358 $this->m->output( "r\n", "bazChannel" );
359 $this->assertOutputPrePostShutdown( "foobar", true );
362 function testOutputWChannelStringNLStringNLArbitraryAgain() {
363 $this->m->output( "", "bazChannel" );
364 $this->m->output( "foo", "bazChannel" );
365 $this->m->output( "", "bazChannel" );
366 $this->m->output( "\nb", "bazChannel" );
367 $this->m->output( "a", "bazChannel" );
368 $this->m->output( "", "bazChannel" );
369 $this->m->output( "r\n", "bazChannel" );
370 $this->assertOutputPrePostShutdown( "foo\nbar", true );
373 function testOutputWMultipleChannelsChannelChange() {
374 $this->m->output( "foo", "bazChannel" );
375 $this->m->output( "bar", "bazChannel" );
376 $this->m->output( "qux", "quuxChannel" );
377 $this->m->output( "corge", "bazChannel" );
378 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
381 function testOutputWMultipleChannelsChannelChangeNL() {
382 $this->m->output( "foo", "bazChannel" );
383 $this->m->output( "bar\n", "bazChannel" );
384 $this->m->output( "qux\n", "quuxChannel" );
385 $this->m->output( "corge", "bazChannel" );
386 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
389 function testOutputWAndWOChannelStringStartWO() {
390 $this->m->output( "foo" );
391 $this->m->output( "bar", "bazChannel" );
392 $this->m->output( "qux" );
393 $this->m->output( "quux", "bazChannel" );
394 $this->assertOutputPrePostShutdown( "foobar\nquxquux", true );
397 function testOutputWAndWOChannelStringStartW() {
398 $this->m->output( "foo", "bazChannel" );
399 $this->m->output( "bar" );
400 $this->m->output( "qux", "bazChannel" );
401 $this->m->output( "quux" );
402 $this->assertOutputPrePostShutdown( "foo\nbarqux\nquux", false );
405 function testOutputWChannelTypeSwitch() {
406 $this->m->output( "foo", 1 );
407 $this->m->output( "bar", 1.0 );
408 $this->assertOutputPrePostShutdown( "foo\nbar", true );
411 function testOutputIntermittentEmpty() {
412 $this->m->output( "foo" );
413 $this->m->output( "" );
414 $this->m->output( "bar" );
415 $this->assertOutputPrePostShutdown( "foobar", false );
418 function testOutputIntermittentFalse() {
419 $this->m->output( "foo" );
420 $this->m->output( false );
421 $this->m->output( "bar" );
422 $this->assertOutputPrePostShutdown( "foobar", false );
425 function testOutputIntermittentFalseAfterOtherChannel() {
426 $this->m->output( "qux", "quuxChannel" );
427 $this->m->output( "foo" );
428 $this->m->output( false );
429 $this->m->output( "bar" );
430 $this->assertOutputPrePostShutdown( "qux\nfoobar", false );
433 function testOutputWNullChannelIntermittentEmpty() {
434 $this->m->output( "foo", null );
435 $this->m->output( "", null );
436 $this->m->output( "bar", null );
437 $this->assertOutputPrePostShutdown( "foobar", false );
440 function testOutputWNullChannelIntermittentFalse() {
441 $this->m->output( "foo", null );
442 $this->m->output( false, null );
443 $this->m->output( "bar", null );
444 $this->assertOutputPrePostShutdown( "foobar", false );
447 function testOutputWChannelIntermittentEmpty() {
448 $this->m->output( "foo", "bazChannel" );
449 $this->m->output( "", "bazChannel" );
450 $this->m->output( "bar", "bazChannel" );
451 $this->assertOutputPrePostShutdown( "foobar", true );
454 function testOutputWChannelIntermittentFalse() {
455 $this->m->output( "foo", "bazChannel" );
456 $this->m->output( false, "bazChannel" );
457 $this->m->output( "bar", "bazChannel" );
458 $this->assertOutputPrePostShutdown( "foobar", true );
461 // Note that (per documentation) outputChanneled does take strings that end
462 // in \n, hence we do not test such strings.
464 function testOutputChanneledEmpty() {
465 $this->m->outputChanneled( "" );
466 $this->assertOutputPrePostShutdown( "\n", false );
469 function testOutputChanneledString() {
470 $this->m->outputChanneled( "foo" );
471 $this->assertOutputPrePostShutdown( "foo\n", false );
474 function testOutputChanneledStringString() {
475 $this->m->outputChanneled( "foo" );
476 $this->m->outputChanneled( "bar" );
477 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
480 function testOutputChanneledStringNLString() {
481 $this->m->outputChanneled( "foo\nbar" );
482 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
485 function testOutputChanneledStringNLStringNLArbitraryAgain() {
486 $this->m->outputChanneled( "" );
487 $this->m->outputChanneled( "foo" );
488 $this->m->outputChanneled( "" );
489 $this->m->outputChanneled( "\nb" );
490 $this->m->outputChanneled( "a" );
491 $this->m->outputChanneled( "" );
492 $this->m->outputChanneled( "r" );
493 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
496 function testOutputChanneledWNullChannelEmpty() {
497 $this->m->outputChanneled( "", null );
498 $this->assertOutputPrePostShutdown( "\n", false );
501 function testOutputChanneledWNullChannelString() {
502 $this->m->outputChanneled( "foo", null );
503 $this->assertOutputPrePostShutdown( "foo\n", false );
506 function testOutputChanneledWNullChannelStringString() {
507 $this->m->outputChanneled( "foo", null );
508 $this->m->outputChanneled( "bar", null );
509 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
512 function testOutputChanneledWNullChannelStringNLString() {
513 $this->m->outputChanneled( "foo\nbar", null );
514 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
517 function testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain() {
518 $this->m->outputChanneled( "", null );
519 $this->m->outputChanneled( "foo", null );
520 $this->m->outputChanneled( "", null );
521 $this->m->outputChanneled( "\nb", null );
522 $this->m->outputChanneled( "a", null );
523 $this->m->outputChanneled( "", null );
524 $this->m->outputChanneled( "r", null );
525 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
528 function testOutputChanneledWChannelString() {
529 $this->m->outputChanneled( "foo", "bazChannel" );
530 $this->assertOutputPrePostShutdown( "foo", true );
533 function testOutputChanneledWChannelStringNLString() {
534 $this->m->outputChanneled( "foo\nbar", "bazChannel" );
535 $this->assertOutputPrePostShutdown( "foo\nbar", true );
538 function testOutputChanneledWChannelStringString() {
539 $this->m->outputChanneled( "foo", "bazChannel" );
540 $this->m->outputChanneled( "bar", "bazChannel" );
541 $this->assertOutputPrePostShutdown( "foobar", true );
544 function testOutputChanneledWChannelStringNLStringNLArbitraryAgain() {
545 $this->m->outputChanneled( "", "bazChannel" );
546 $this->m->outputChanneled( "foo", "bazChannel" );
547 $this->m->outputChanneled( "", "bazChannel" );
548 $this->m->outputChanneled( "\nb", "bazChannel" );
549 $this->m->outputChanneled( "a", "bazChannel" );
550 $this->m->outputChanneled( "", "bazChannel" );
551 $this->m->outputChanneled( "r", "bazChannel" );
552 $this->assertOutputPrePostShutdown( "foo\nbar", true );
555 function testOutputChanneledWMultipleChannelsChannelChange() {
556 $this->m->outputChanneled( "foo", "bazChannel" );
557 $this->m->outputChanneled( "bar", "bazChannel" );
558 $this->m->outputChanneled( "qux", "quuxChannel" );
559 $this->m->outputChanneled( "corge", "bazChannel" );
560 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
563 function testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull() {
564 $this->m->outputChanneled( "foo", "bazChannel" );
565 $this->m->outputChanneled( "bar", null );
566 $this->m->outputChanneled( "qux", null );
567 $this->m->outputChanneled( "corge", "bazChannel" );
568 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
571 function testOutputChanneledWMultipleChannelsChannelAfterNullChange() {
572 $this->m->outputChanneled( "foo", "bazChannel" );
573 $this->m->outputChanneled( "bar", null );
574 $this->m->outputChanneled( "qux", null );
575 $this->m->outputChanneled( "corge", "quuxChannel" );
576 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
579 function testOutputChanneledWAndWOChannelStringStartWO() {
580 $this->m->outputChanneled( "foo" );
581 $this->m->outputChanneled( "bar", "bazChannel" );
582 $this->m->outputChanneled( "qux" );
583 $this->m->outputChanneled( "quux", "bazChannel" );
584 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux", true );
587 function testOutputChanneledWAndWOChannelStringStartW() {
588 $this->m->outputChanneled( "foo", "bazChannel" );
589 $this->m->outputChanneled( "bar" );
590 $this->m->outputChanneled( "qux", "bazChannel" );
591 $this->m->outputChanneled( "quux" );
592 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux\n", false );
595 function testOutputChanneledWChannelTypeSwitch() {
596 $this->m->outputChanneled( "foo", 1 );
597 $this->m->outputChanneled( "bar", 1.0 );
598 $this->assertOutputPrePostShutdown( "foo\nbar", true );
601 function testOutputChanneledWOChannelIntermittentEmpty() {
602 $this->m->outputChanneled( "foo" );
603 $this->m->outputChanneled( "" );
604 $this->m->outputChanneled( "bar" );
605 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
608 function testOutputChanneledWOChannelIntermittentFalse() {
609 $this->m->outputChanneled( "foo" );
610 $this->m->outputChanneled( false );
611 $this->m->outputChanneled( "bar" );
612 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
615 function testOutputChanneledWNullChannelIntermittentEmpty() {
616 $this->m->outputChanneled( "foo", null );
617 $this->m->outputChanneled( "", null );
618 $this->m->outputChanneled( "bar", null );
619 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
622 function testOutputChanneledWNullChannelIntermittentFalse() {
623 $this->m->outputChanneled( "foo", null );
624 $this->m->outputChanneled( false, null );
625 $this->m->outputChanneled( "bar", null );
626 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
629 function testOutputChanneledWChannelIntermittentEmpty() {
630 $this->m->outputChanneled( "foo", "bazChannel" );
631 $this->m->outputChanneled( "", "bazChannel" );
632 $this->m->outputChanneled( "bar", "bazChannel" );
633 $this->assertOutputPrePostShutdown( "foobar", true );
636 function testOutputChanneledWChannelIntermittentFalse() {
637 $this->m->outputChanneled( "foo", "bazChannel" );
638 $this->m->outputChanneled( false, "bazChannel" );
639 $this->m->outputChanneled( "bar", "bazChannel" );
640 $this->assertOutputPrePostShutdown( "foo\nbar", true );
643 function testCleanupChanneledClean() {
644 $this->m->cleanupChanneled();
645 $this->assertOutputPrePostShutdown( "", false );
648 function testCleanupChanneledAfterOutput() {
649 $this->m->output( "foo" );
650 $this->m->cleanupChanneled();
651 $this->assertOutputPrePostShutdown( "foo", false );
654 function testCleanupChanneledAfterOutputWNullChannel() {
655 $this->m->output( "foo", null );
656 $this->m->cleanupChanneled();
657 $this->assertOutputPrePostShutdown( "foo", false );
660 function testCleanupChanneledAfterOutputWChannel() {
661 $this->m->output( "foo", "bazChannel" );
662 $this->m->cleanupChanneled();
663 $this->assertOutputPrePostShutdown( "foo\n", false );
666 function testCleanupChanneledAfterNLOutput() {
667 $this->m->output( "foo\n" );
668 $this->m->cleanupChanneled();
669 $this->assertOutputPrePostShutdown( "foo\n", false );
672 function testCleanupChanneledAfterNLOutputWNullChannel() {
673 $this->m->output( "foo\n", null );
674 $this->m->cleanupChanneled();
675 $this->assertOutputPrePostShutdown( "foo\n", false );
678 function testCleanupChanneledAfterNLOutputWChannel() {
679 $this->m->output( "foo\n", "bazChannel" );
680 $this->m->cleanupChanneled();
681 $this->assertOutputPrePostShutdown( "foo\n", false );
684 function testCleanupChanneledAfterOutputChanneledWOChannel() {
685 $this->m->outputChanneled( "foo" );
686 $this->m->cleanupChanneled();
687 $this->assertOutputPrePostShutdown( "foo\n", false );
690 function testCleanupChanneledAfterOutputChanneledWNullChannel() {
691 $this->m->outputChanneled( "foo", null );
692 $this->m->cleanupChanneled();
693 $this->assertOutputPrePostShutdown( "foo\n", false );
696 function testCleanupChanneledAfterOutputChanneledWChannel() {
697 $this->m->outputChanneled( "foo", "bazChannel" );
698 $this->m->cleanupChanneled();
699 $this->assertOutputPrePostShutdown( "foo\n", false );
702 function testMultipleMaintenanceObjectsInteractionOutput() {
703 $m2 = new MaintenanceFixup( $this );
705 $this->m->output( "foo" );
706 $m2->output( "bar" );
708 $this->assertEquals( "foobar", $this->getActualOutput(),
709 "Output before shutdown simulation (m2)" );
710 $m2->simulateShutdown();
711 $this->assertOutputPrePostShutdown( "foobar", false );
714 function testMultipleMaintenanceObjectsInteractionOutputWNullChannel() {
715 $m2 = new MaintenanceFixup( $this );
717 $this->m->output( "foo", null );
718 $m2->output( "bar", null );
720 $this->assertEquals( "foobar", $this->getActualOutput(),
721 "Output before shutdown simulation (m2)" );
722 $m2->simulateShutdown();
723 $this->assertOutputPrePostShutdown( "foobar", false );
726 function testMultipleMaintenanceObjectsInteractionOutputWChannel() {
727 $m2 = new MaintenanceFixup( $this );
729 $this->m->output( "foo", "bazChannel" );
730 $m2->output( "bar", "bazChannel" );
732 $this->assertEquals( "foobar", $this->getActualOutput(),
733 "Output before shutdown simulation (m2)" );
734 $m2->simulateShutdown();
735 $this->assertOutputPrePostShutdown( "foobar\n", true );
738 function testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL() {
739 $m2 = new MaintenanceFixup( $this );
741 $this->m->output( "foo\n", null );
742 $m2->output( "bar\n", null );
744 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
745 "Output before shutdown simulation (m2)" );
746 $m2->simulateShutdown();
747 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
750 function testMultipleMaintenanceObjectsInteractionOutputWChannelNL() {
751 $m2 = new MaintenanceFixup( $this );
753 $this->m->output( "foo\n", "bazChannel" );
754 $m2->output( "bar\n", "bazChannel" );
756 $this->assertEquals( "foobar", $this->getActualOutput(),
757 "Output before shutdown simulation (m2)" );
758 $m2->simulateShutdown();
759 $this->assertOutputPrePostShutdown( "foobar\n", true );
762 function testMultipleMaintenanceObjectsInteractionOutputChanneled() {
763 $m2 = new MaintenanceFixup( $this );
765 $this->m->outputChanneled( "foo" );
766 $m2->outputChanneled( "bar" );
768 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
769 "Output before shutdown simulation (m2)" );
770 $m2->simulateShutdown();
771 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
774 function testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel() {
775 $m2 = new MaintenanceFixup( $this );
777 $this->m->outputChanneled( "foo", null );
778 $m2->outputChanneled( "bar", null );
780 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
781 "Output before shutdown simulation (m2)" );
782 $m2->simulateShutdown();
783 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
786 function testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel() {
787 $m2 = new MaintenanceFixup( $this );
789 $this->m->outputChanneled( "foo", "bazChannel" );
790 $m2->outputChanneled( "bar", "bazChannel" );
792 $this->assertEquals( "foobar", $this->getActualOutput(),
793 "Output before shutdown simulation (m2)" );
794 $m2->simulateShutdown();
795 $this->assertOutputPrePostShutdown( "foobar\n", true );
798 function testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel() {
799 $m2 = new MaintenanceFixup( $this );
801 $this->m->outputChanneled( "foo", "bazChannel" );
802 $m2->outputChanneled( "bar", "bazChannel" );
804 $this->assertEquals( "foobar", $this->getActualOutput(),
805 "Output before first cleanup" );
806 $this->m->cleanupChanneled();
807 $this->assertEquals( "foobar\n", $this->getActualOutput(),
808 "Output after first cleanup" );
809 $m2->cleanupChanneled();
810 $this->assertEquals( "foobar\n\n", $this->getActualOutput(),
811 "Output after second cleanup" );
813 $m2->simulateShutdown();
814 $this->assertOutputPrePostShutdown( "foobar\n\n", false );