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 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 class MaintenanceTest
extends MediaWikiTestCase
{
138 * The main Maintenance instance that is used for testing.
140 * @var MaintenanceFixup
145 protected function setUp() {
147 $this->m
= new MaintenanceFixup( $this );
150 protected function tearDown() {
152 $this->m
->simulateShutdown();
160 * asserts the output before and after simulating shutdown
162 * This function simulates shutdown of self::m.
164 * @param $preShutdownOutput string: expected output before simulating shutdown
165 * @param $expectNLAppending bool: Whether or not shutdown simulation is expected
166 * to add a newline to the output. If false, $preShutdownOutput is the
167 * expected output after shutdown simulation. Otherwise,
168 * $preShutdownOutput with an appended newline is the expected output
169 * after shutdown simulation.
171 private function assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending ) {
173 $this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
174 "Output before shutdown simulation" );
176 $this->m
->simulateShutdown();
179 $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ?
"\n" : "" );
180 $this->expectOutputString( $postShutdownOutput );
184 // Although the following tests do not seem to be too consistent (compare for
185 // example the newlines within the test.*StringString tests, or the
186 // test.*Intermittent.* tests), the objective of these tests is not to describe
187 // consistent behavior, but rather currently existing behavior.
190 function testOutputEmpty() {
191 $this->m
->output( "" );
192 $this->assertOutputPrePostShutdown( "", false );
195 function testOutputString() {
196 $this->m
->output( "foo" );
197 $this->assertOutputPrePostShutdown( "foo", false );
200 function testOutputStringString() {
201 $this->m
->output( "foo" );
202 $this->m
->output( "bar" );
203 $this->assertOutputPrePostShutdown( "foobar", false );
206 function testOutputStringNL() {
207 $this->m
->output( "foo\n" );
208 $this->assertOutputPrePostShutdown( "foo\n", false );
211 function testOutputStringNLNL() {
212 $this->m
->output( "foo\n\n" );
213 $this->assertOutputPrePostShutdown( "foo\n\n", false );
216 function testOutputStringNLString() {
217 $this->m
->output( "foo\nbar" );
218 $this->assertOutputPrePostShutdown( "foo\nbar", false );
221 function testOutputStringNLStringNL() {
222 $this->m
->output( "foo\nbar\n" );
223 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
226 function testOutputStringNLStringNLLinewise() {
227 $this->m
->output( "foo\n" );
228 $this->m
->output( "bar\n" );
229 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
232 function testOutputStringNLStringNLArbitrary() {
233 $this->m
->output( "" );
234 $this->m
->output( "foo" );
235 $this->m
->output( "" );
236 $this->m
->output( "\n" );
237 $this->m
->output( "ba" );
238 $this->m
->output( "" );
239 $this->m
->output( "r\n" );
240 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
243 function testOutputStringNLStringNLArbitraryAgain() {
244 $this->m
->output( "" );
245 $this->m
->output( "foo" );
246 $this->m
->output( "" );
247 $this->m
->output( "\nb" );
248 $this->m
->output( "a" );
249 $this->m
->output( "" );
250 $this->m
->output( "r\n" );
251 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
254 function testOutputWNullChannelEmpty() {
255 $this->m
->output( "", null );
256 $this->assertOutputPrePostShutdown( "", false );
259 function testOutputWNullChannelString() {
260 $this->m
->output( "foo", null );
261 $this->assertOutputPrePostShutdown( "foo", false );
264 function testOutputWNullChannelStringString() {
265 $this->m
->output( "foo", null );
266 $this->m
->output( "bar", null );
267 $this->assertOutputPrePostShutdown( "foobar", false );
270 function testOutputWNullChannelStringNL() {
271 $this->m
->output( "foo\n", null );
272 $this->assertOutputPrePostShutdown( "foo\n", false );
275 function testOutputWNullChannelStringNLNL() {
276 $this->m
->output( "foo\n\n", null );
277 $this->assertOutputPrePostShutdown( "foo\n\n", false );
280 function testOutputWNullChannelStringNLString() {
281 $this->m
->output( "foo\nbar", null );
282 $this->assertOutputPrePostShutdown( "foo\nbar", false );
285 function testOutputWNullChannelStringNLStringNL() {
286 $this->m
->output( "foo\nbar\n", null );
287 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
290 function testOutputWNullChannelStringNLStringNLLinewise() {
291 $this->m
->output( "foo\n", null );
292 $this->m
->output( "bar\n", null );
293 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
296 function testOutputWNullChannelStringNLStringNLArbitrary() {
297 $this->m
->output( "", null );
298 $this->m
->output( "foo", null );
299 $this->m
->output( "", null );
300 $this->m
->output( "\n", null );
301 $this->m
->output( "ba", null );
302 $this->m
->output( "", null );
303 $this->m
->output( "r\n", null );
304 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
307 function testOutputWNullChannelStringNLStringNLArbitraryAgain() {
308 $this->m
->output( "", null );
309 $this->m
->output( "foo", null );
310 $this->m
->output( "", null );
311 $this->m
->output( "\nb", null );
312 $this->m
->output( "a", null );
313 $this->m
->output( "", null );
314 $this->m
->output( "r\n", null );
315 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
318 function testOutputWChannelString() {
319 $this->m
->output( "foo", "bazChannel" );
320 $this->assertOutputPrePostShutdown( "foo", true );
323 function testOutputWChannelStringNL() {
324 $this->m
->output( "foo\n", "bazChannel" );
325 $this->assertOutputPrePostShutdown( "foo", true );
328 function testOutputWChannelStringNLNL() {
329 // If this test fails, note that output takes strings with double line
330 // endings (although output's implementation in this situation calls
331 // outputChanneled with a string ending in a nl ... which is not allowed
332 // according to the documentation of outputChanneled)
333 $this->m
->output( "foo\n\n", "bazChannel" );
334 $this->assertOutputPrePostShutdown( "foo\n", true );
337 function testOutputWChannelStringNLString() {
338 $this->m
->output( "foo\nbar", "bazChannel" );
339 $this->assertOutputPrePostShutdown( "foo\nbar", true );
342 function testOutputWChannelStringNLStringNL() {
343 $this->m
->output( "foo\nbar\n", "bazChannel" );
344 $this->assertOutputPrePostShutdown( "foo\nbar", true );
347 function testOutputWChannelStringNLStringNLLinewise() {
348 $this->m
->output( "foo\n", "bazChannel" );
349 $this->m
->output( "bar\n", "bazChannel" );
350 $this->assertOutputPrePostShutdown( "foobar", true );
353 function testOutputWChannelStringNLStringNLArbitrary() {
354 $this->m
->output( "", "bazChannel" );
355 $this->m
->output( "foo", "bazChannel" );
356 $this->m
->output( "", "bazChannel" );
357 $this->m
->output( "\n", "bazChannel" );
358 $this->m
->output( "ba", "bazChannel" );
359 $this->m
->output( "", "bazChannel" );
360 $this->m
->output( "r\n", "bazChannel" );
361 $this->assertOutputPrePostShutdown( "foobar", true );
364 function testOutputWChannelStringNLStringNLArbitraryAgain() {
365 $this->m
->output( "", "bazChannel" );
366 $this->m
->output( "foo", "bazChannel" );
367 $this->m
->output( "", "bazChannel" );
368 $this->m
->output( "\nb", "bazChannel" );
369 $this->m
->output( "a", "bazChannel" );
370 $this->m
->output( "", "bazChannel" );
371 $this->m
->output( "r\n", "bazChannel" );
372 $this->assertOutputPrePostShutdown( "foo\nbar", true );
375 function testOutputWMultipleChannelsChannelChange() {
376 $this->m
->output( "foo", "bazChannel" );
377 $this->m
->output( "bar", "bazChannel" );
378 $this->m
->output( "qux", "quuxChannel" );
379 $this->m
->output( "corge", "bazChannel" );
380 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
383 function testOutputWMultipleChannelsChannelChangeNL() {
384 $this->m
->output( "foo", "bazChannel" );
385 $this->m
->output( "bar\n", "bazChannel" );
386 $this->m
->output( "qux\n", "quuxChannel" );
387 $this->m
->output( "corge", "bazChannel" );
388 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
391 function testOutputWAndWOChannelStringStartWO() {
392 $this->m
->output( "foo" );
393 $this->m
->output( "bar", "bazChannel" );
394 $this->m
->output( "qux" );
395 $this->m
->output( "quux", "bazChannel" );
396 $this->assertOutputPrePostShutdown( "foobar\nquxquux", true );
399 function testOutputWAndWOChannelStringStartW() {
400 $this->m
->output( "foo", "bazChannel" );
401 $this->m
->output( "bar" );
402 $this->m
->output( "qux", "bazChannel" );
403 $this->m
->output( "quux" );
404 $this->assertOutputPrePostShutdown( "foo\nbarqux\nquux", false );
407 function testOutputWChannelTypeSwitch() {
408 $this->m
->output( "foo", 1 );
409 $this->m
->output( "bar", 1.0 );
410 $this->assertOutputPrePostShutdown( "foo\nbar", true );
413 function testOutputIntermittentEmpty() {
414 $this->m
->output( "foo" );
415 $this->m
->output( "" );
416 $this->m
->output( "bar" );
417 $this->assertOutputPrePostShutdown( "foobar", false );
420 function testOutputIntermittentFalse() {
421 $this->m
->output( "foo" );
422 $this->m
->output( false );
423 $this->m
->output( "bar" );
424 $this->assertOutputPrePostShutdown( "foobar", false );
427 function testOutputIntermittentFalseAfterOtherChannel() {
428 $this->m
->output( "qux", "quuxChannel" );
429 $this->m
->output( "foo" );
430 $this->m
->output( false );
431 $this->m
->output( "bar" );
432 $this->assertOutputPrePostShutdown( "qux\nfoobar", false );
435 function testOutputWNullChannelIntermittentEmpty() {
436 $this->m
->output( "foo", null );
437 $this->m
->output( "", null );
438 $this->m
->output( "bar", null );
439 $this->assertOutputPrePostShutdown( "foobar", false );
442 function testOutputWNullChannelIntermittentFalse() {
443 $this->m
->output( "foo", null );
444 $this->m
->output( false, null );
445 $this->m
->output( "bar", null );
446 $this->assertOutputPrePostShutdown( "foobar", false );
449 function testOutputWChannelIntermittentEmpty() {
450 $this->m
->output( "foo", "bazChannel" );
451 $this->m
->output( "", "bazChannel" );
452 $this->m
->output( "bar", "bazChannel" );
453 $this->assertOutputPrePostShutdown( "foobar", true );
456 function testOutputWChannelIntermittentFalse() {
457 $this->m
->output( "foo", "bazChannel" );
458 $this->m
->output( false, "bazChannel" );
459 $this->m
->output( "bar", "bazChannel" );
460 $this->assertOutputPrePostShutdown( "foobar", true );
463 // Note that (per documentation) outputChanneled does take strings that end
464 // in \n, hence we do not test such strings.
466 function testOutputChanneledEmpty() {
467 $this->m
->outputChanneled( "" );
468 $this->assertOutputPrePostShutdown( "\n", false );
471 function testOutputChanneledString() {
472 $this->m
->outputChanneled( "foo" );
473 $this->assertOutputPrePostShutdown( "foo\n", false );
476 function testOutputChanneledStringString() {
477 $this->m
->outputChanneled( "foo" );
478 $this->m
->outputChanneled( "bar" );
479 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
482 function testOutputChanneledStringNLString() {
483 $this->m
->outputChanneled( "foo\nbar" );
484 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
487 function testOutputChanneledStringNLStringNLArbitraryAgain() {
488 $this->m
->outputChanneled( "" );
489 $this->m
->outputChanneled( "foo" );
490 $this->m
->outputChanneled( "" );
491 $this->m
->outputChanneled( "\nb" );
492 $this->m
->outputChanneled( "a" );
493 $this->m
->outputChanneled( "" );
494 $this->m
->outputChanneled( "r" );
495 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
498 function testOutputChanneledWNullChannelEmpty() {
499 $this->m
->outputChanneled( "", null );
500 $this->assertOutputPrePostShutdown( "\n", false );
503 function testOutputChanneledWNullChannelString() {
504 $this->m
->outputChanneled( "foo", null );
505 $this->assertOutputPrePostShutdown( "foo\n", false );
508 function testOutputChanneledWNullChannelStringString() {
509 $this->m
->outputChanneled( "foo", null );
510 $this->m
->outputChanneled( "bar", null );
511 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
514 function testOutputChanneledWNullChannelStringNLString() {
515 $this->m
->outputChanneled( "foo\nbar", null );
516 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
519 function testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain() {
520 $this->m
->outputChanneled( "", null );
521 $this->m
->outputChanneled( "foo", null );
522 $this->m
->outputChanneled( "", null );
523 $this->m
->outputChanneled( "\nb", null );
524 $this->m
->outputChanneled( "a", null );
525 $this->m
->outputChanneled( "", null );
526 $this->m
->outputChanneled( "r", null );
527 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
530 function testOutputChanneledWChannelString() {
531 $this->m
->outputChanneled( "foo", "bazChannel" );
532 $this->assertOutputPrePostShutdown( "foo", true );
535 function testOutputChanneledWChannelStringNLString() {
536 $this->m
->outputChanneled( "foo\nbar", "bazChannel" );
537 $this->assertOutputPrePostShutdown( "foo\nbar", true );
540 function testOutputChanneledWChannelStringString() {
541 $this->m
->outputChanneled( "foo", "bazChannel" );
542 $this->m
->outputChanneled( "bar", "bazChannel" );
543 $this->assertOutputPrePostShutdown( "foobar", true );
546 function testOutputChanneledWChannelStringNLStringNLArbitraryAgain() {
547 $this->m
->outputChanneled( "", "bazChannel" );
548 $this->m
->outputChanneled( "foo", "bazChannel" );
549 $this->m
->outputChanneled( "", "bazChannel" );
550 $this->m
->outputChanneled( "\nb", "bazChannel" );
551 $this->m
->outputChanneled( "a", "bazChannel" );
552 $this->m
->outputChanneled( "", "bazChannel" );
553 $this->m
->outputChanneled( "r", "bazChannel" );
554 $this->assertOutputPrePostShutdown( "foo\nbar", true );
557 function testOutputChanneledWMultipleChannelsChannelChange() {
558 $this->m
->outputChanneled( "foo", "bazChannel" );
559 $this->m
->outputChanneled( "bar", "bazChannel" );
560 $this->m
->outputChanneled( "qux", "quuxChannel" );
561 $this->m
->outputChanneled( "corge", "bazChannel" );
562 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
565 function testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull() {
566 $this->m
->outputChanneled( "foo", "bazChannel" );
567 $this->m
->outputChanneled( "bar", null );
568 $this->m
->outputChanneled( "qux", null );
569 $this->m
->outputChanneled( "corge", "bazChannel" );
570 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
573 function testOutputChanneledWMultipleChannelsChannelAfterNullChange() {
574 $this->m
->outputChanneled( "foo", "bazChannel" );
575 $this->m
->outputChanneled( "bar", null );
576 $this->m
->outputChanneled( "qux", null );
577 $this->m
->outputChanneled( "corge", "quuxChannel" );
578 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
581 function testOutputChanneledWAndWOChannelStringStartWO() {
582 $this->m
->outputChanneled( "foo" );
583 $this->m
->outputChanneled( "bar", "bazChannel" );
584 $this->m
->outputChanneled( "qux" );
585 $this->m
->outputChanneled( "quux", "bazChannel" );
586 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux", true );
589 function testOutputChanneledWAndWOChannelStringStartW() {
590 $this->m
->outputChanneled( "foo", "bazChannel" );
591 $this->m
->outputChanneled( "bar" );
592 $this->m
->outputChanneled( "qux", "bazChannel" );
593 $this->m
->outputChanneled( "quux" );
594 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux\n", false );
597 function testOutputChanneledWChannelTypeSwitch() {
598 $this->m
->outputChanneled( "foo", 1 );
599 $this->m
->outputChanneled( "bar", 1.0 );
600 $this->assertOutputPrePostShutdown( "foo\nbar", true );
603 function testOutputChanneledWOChannelIntermittentEmpty() {
604 $this->m
->outputChanneled( "foo" );
605 $this->m
->outputChanneled( "" );
606 $this->m
->outputChanneled( "bar" );
607 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
610 function testOutputChanneledWOChannelIntermittentFalse() {
611 $this->m
->outputChanneled( "foo" );
612 $this->m
->outputChanneled( false );
613 $this->m
->outputChanneled( "bar" );
614 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
617 function testOutputChanneledWNullChannelIntermittentEmpty() {
618 $this->m
->outputChanneled( "foo", null );
619 $this->m
->outputChanneled( "", null );
620 $this->m
->outputChanneled( "bar", null );
621 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
624 function testOutputChanneledWNullChannelIntermittentFalse() {
625 $this->m
->outputChanneled( "foo", null );
626 $this->m
->outputChanneled( false, null );
627 $this->m
->outputChanneled( "bar", null );
628 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
631 function testOutputChanneledWChannelIntermittentEmpty() {
632 $this->m
->outputChanneled( "foo", "bazChannel" );
633 $this->m
->outputChanneled( "", "bazChannel" );
634 $this->m
->outputChanneled( "bar", "bazChannel" );
635 $this->assertOutputPrePostShutdown( "foobar", true );
638 function testOutputChanneledWChannelIntermittentFalse() {
639 $this->m
->outputChanneled( "foo", "bazChannel" );
640 $this->m
->outputChanneled( false, "bazChannel" );
641 $this->m
->outputChanneled( "bar", "bazChannel" );
642 $this->assertOutputPrePostShutdown( "foo\nbar", true );
645 function testCleanupChanneledClean() {
646 $this->m
->cleanupChanneled();
647 $this->assertOutputPrePostShutdown( "", false );
650 function testCleanupChanneledAfterOutput() {
651 $this->m
->output( "foo" );
652 $this->m
->cleanupChanneled();
653 $this->assertOutputPrePostShutdown( "foo", false );
656 function testCleanupChanneledAfterOutputWNullChannel() {
657 $this->m
->output( "foo", null );
658 $this->m
->cleanupChanneled();
659 $this->assertOutputPrePostShutdown( "foo", false );
662 function testCleanupChanneledAfterOutputWChannel() {
663 $this->m
->output( "foo", "bazChannel" );
664 $this->m
->cleanupChanneled();
665 $this->assertOutputPrePostShutdown( "foo\n", false );
668 function testCleanupChanneledAfterNLOutput() {
669 $this->m
->output( "foo\n" );
670 $this->m
->cleanupChanneled();
671 $this->assertOutputPrePostShutdown( "foo\n", false );
674 function testCleanupChanneledAfterNLOutputWNullChannel() {
675 $this->m
->output( "foo\n", null );
676 $this->m
->cleanupChanneled();
677 $this->assertOutputPrePostShutdown( "foo\n", false );
680 function testCleanupChanneledAfterNLOutputWChannel() {
681 $this->m
->output( "foo\n", "bazChannel" );
682 $this->m
->cleanupChanneled();
683 $this->assertOutputPrePostShutdown( "foo\n", false );
686 function testCleanupChanneledAfterOutputChanneledWOChannel() {
687 $this->m
->outputChanneled( "foo" );
688 $this->m
->cleanupChanneled();
689 $this->assertOutputPrePostShutdown( "foo\n", false );
692 function testCleanupChanneledAfterOutputChanneledWNullChannel() {
693 $this->m
->outputChanneled( "foo", null );
694 $this->m
->cleanupChanneled();
695 $this->assertOutputPrePostShutdown( "foo\n", false );
698 function testCleanupChanneledAfterOutputChanneledWChannel() {
699 $this->m
->outputChanneled( "foo", "bazChannel" );
700 $this->m
->cleanupChanneled();
701 $this->assertOutputPrePostShutdown( "foo\n", false );
704 function testMultipleMaintenanceObjectsInteractionOutput() {
705 $m2 = new MaintenanceFixup( $this );
707 $this->m
->output( "foo" );
708 $m2->output( "bar" );
710 $this->assertEquals( "foobar", $this->getActualOutput(),
711 "Output before shutdown simulation (m2)" );
712 $m2->simulateShutdown();
713 $this->assertOutputPrePostShutdown( "foobar", false );
716 function testMultipleMaintenanceObjectsInteractionOutputWNullChannel() {
717 $m2 = new MaintenanceFixup( $this );
719 $this->m
->output( "foo", null );
720 $m2->output( "bar", null );
722 $this->assertEquals( "foobar", $this->getActualOutput(),
723 "Output before shutdown simulation (m2)" );
724 $m2->simulateShutdown();
725 $this->assertOutputPrePostShutdown( "foobar", false );
728 function testMultipleMaintenanceObjectsInteractionOutputWChannel() {
729 $m2 = new MaintenanceFixup( $this );
731 $this->m
->output( "foo", "bazChannel" );
732 $m2->output( "bar", "bazChannel" );
734 $this->assertEquals( "foobar", $this->getActualOutput(),
735 "Output before shutdown simulation (m2)" );
736 $m2->simulateShutdown();
737 $this->assertOutputPrePostShutdown( "foobar\n", true );
740 function testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL() {
741 $m2 = new MaintenanceFixup( $this );
743 $this->m
->output( "foo\n", null );
744 $m2->output( "bar\n", null );
746 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
747 "Output before shutdown simulation (m2)" );
748 $m2->simulateShutdown();
749 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
752 function testMultipleMaintenanceObjectsInteractionOutputWChannelNL() {
753 $m2 = new MaintenanceFixup( $this );
755 $this->m
->output( "foo\n", "bazChannel" );
756 $m2->output( "bar\n", "bazChannel" );
758 $this->assertEquals( "foobar", $this->getActualOutput(),
759 "Output before shutdown simulation (m2)" );
760 $m2->simulateShutdown();
761 $this->assertOutputPrePostShutdown( "foobar\n", true );
764 function testMultipleMaintenanceObjectsInteractionOutputChanneled() {
765 $m2 = new MaintenanceFixup( $this );
767 $this->m
->outputChanneled( "foo" );
768 $m2->outputChanneled( "bar" );
770 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
771 "Output before shutdown simulation (m2)" );
772 $m2->simulateShutdown();
773 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
776 function testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel() {
777 $m2 = new MaintenanceFixup( $this );
779 $this->m
->outputChanneled( "foo", null );
780 $m2->outputChanneled( "bar", null );
782 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
783 "Output before shutdown simulation (m2)" );
784 $m2->simulateShutdown();
785 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
788 function testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel() {
789 $m2 = new MaintenanceFixup( $this );
791 $this->m
->outputChanneled( "foo", "bazChannel" );
792 $m2->outputChanneled( "bar", "bazChannel" );
794 $this->assertEquals( "foobar", $this->getActualOutput(),
795 "Output before shutdown simulation (m2)" );
796 $m2->simulateShutdown();
797 $this->assertOutputPrePostShutdown( "foobar\n", true );
800 function testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel() {
801 $m2 = new MaintenanceFixup( $this );
803 $this->m
->outputChanneled( "foo", "bazChannel" );
804 $m2->outputChanneled( "bar", "bazChannel" );
806 $this->assertEquals( "foobar", $this->getActualOutput(),
807 "Output before first cleanup" );
808 $this->m
->cleanupChanneled();
809 $this->assertEquals( "foobar\n", $this->getActualOutput(),
810 "Output after first cleanup" );
811 $m2->cleanupChanneled();
812 $this->assertEquals( "foobar\n\n", $this->getActualOutput(),
813 "Output after second cleanup" );
815 $m2->simulateShutdown();
816 $this->assertOutputPrePostShutdown( "foobar\n\n", false );