Localisation updates from http://translatewiki.net.
[mediawiki.git] / tests / phpunit / maintenance / MaintenanceTest.php
blob4a6f08fa4fe0f86a8d867ff041f1817e70572a4e
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 ) && ( ! $this->testCase->hasFailed() ) ) {
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 fwrite( STDERR, "ERROR! Instance of " . __CLASS__ . " destructed without "
98 . "calling simulateShutdown method. Call simulateShutdown on the "
99 . "instance before it gets destructed." );
102 // The following guard is required, as PHP does not offer default destructors :(
103 if ( is_callable( "parent::__destruct" ) ) {
104 parent::__destruct();
108 public function __construct( MediaWikiTestCase $testCase ) {
109 parent::__construct();
110 $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() );
127 // --- Requirements for getting instance of abstract class
129 public function execute() {
130 $this->testCase->fail( __METHOD__ . " called unexpectedly" );
135 class MaintenanceTest extends MediaWikiTestCase {
139 * The main Maintenance instance that is used for testing.
141 * @var MaintenanceFixup
143 private $m;
146 protected function setUp() {
147 parent::setUp();
148 $this->m = new MaintenanceFixup( $this );
153 * asserts the output before and after simulating shutdown
155 * This function simulates shutdown of self::m.
157 * @param $preShutdownOutput string: expected output before simulating shutdown
158 * @param $expectNLAppending bool: Whether or not shutdown simulation is expected
159 * to add a newline to the output. If false, $preShutdownOutput is the
160 * expected output after shutdown simulation. Otherwise,
161 * $preShutdownOutput with an appended newline is the expected output
162 * after shutdown simulation.
164 private function assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending ) {
166 $this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
167 "Output before shutdown simulation" );
169 $this->m->simulateShutdown();
171 $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ? "\n" : "" );
172 $this->expectOutputString( $postShutdownOutput );
176 // Although the following tests do not seem to be too consistent (compare for
177 // example the newlines within the test.*StringString tests, or the
178 // test.*Intermittent.* tests), the objective of these tests is not to describe
179 // consistent behaviour, but rather currently existing behaviour.
182 function testOutputEmpty() {
183 $this->m->output( "" );
184 $this->assertOutputPrePostShutdown( "", False );
187 function testOutputString() {
188 $this->m->output( "foo" );
189 $this->assertOutputPrePostShutdown( "foo", False );
192 function testOutputStringString() {
193 $this->m->output( "foo" );
194 $this->m->output( "bar" );
195 $this->assertOutputPrePostShutdown( "foobar", False );
198 function testOutputStringNL() {
199 $this->m->output( "foo\n" );
200 $this->assertOutputPrePostShutdown( "foo\n", False );
203 function testOutputStringNLNL() {
204 $this->m->output( "foo\n\n" );
205 $this->assertOutputPrePostShutdown( "foo\n\n", False );
208 function testOutputStringNLString() {
209 $this->m->output( "foo\nbar" );
210 $this->assertOutputPrePostShutdown( "foo\nbar", False );
213 function testOutputStringNLStringNL() {
214 $this->m->output( "foo\nbar\n" );
215 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
218 function testOutputStringNLStringNLLinewise() {
219 $this->m->output( "foo\n" );
220 $this->m->output( "bar\n" );
221 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
224 function testOutputStringNLStringNLArbitrary() {
225 $this->m->output( "" );
226 $this->m->output( "foo" );
227 $this->m->output( "" );
228 $this->m->output( "\n" );
229 $this->m->output( "ba" );
230 $this->m->output( "" );
231 $this->m->output( "r\n" );
232 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
235 function testOutputStringNLStringNLArbitraryAgain() {
236 $this->m->output( "" );
237 $this->m->output( "foo" );
238 $this->m->output( "" );
239 $this->m->output( "\nb" );
240 $this->m->output( "a" );
241 $this->m->output( "" );
242 $this->m->output( "r\n" );
243 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
246 function testOutputWNullChannelEmpty() {
247 $this->m->output( "", null );
248 $this->assertOutputPrePostShutdown( "", False );
251 function testOutputWNullChannelString() {
252 $this->m->output( "foo", null );
253 $this->assertOutputPrePostShutdown( "foo", False );
256 function testOutputWNullChannelStringString() {
257 $this->m->output( "foo", null );
258 $this->m->output( "bar", null );
259 $this->assertOutputPrePostShutdown( "foobar", False );
262 function testOutputWNullChannelStringNL() {
263 $this->m->output( "foo\n", null );
264 $this->assertOutputPrePostShutdown( "foo\n", False );
267 function testOutputWNullChannelStringNLNL() {
268 $this->m->output( "foo\n\n", null );
269 $this->assertOutputPrePostShutdown( "foo\n\n", False );
272 function testOutputWNullChannelStringNLString() {
273 $this->m->output( "foo\nbar", null );
274 $this->assertOutputPrePostShutdown( "foo\nbar", False );
277 function testOutputWNullChannelStringNLStringNL() {
278 $this->m->output( "foo\nbar\n", null );
279 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
282 function testOutputWNullChannelStringNLStringNLLinewise() {
283 $this->m->output( "foo\n", null );
284 $this->m->output( "bar\n", null );
285 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
288 function testOutputWNullChannelStringNLStringNLArbitrary() {
289 $this->m->output( "", null );
290 $this->m->output( "foo", null );
291 $this->m->output( "", null );
292 $this->m->output( "\n", null );
293 $this->m->output( "ba", null );
294 $this->m->output( "", null );
295 $this->m->output( "r\n", null );
296 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
299 function testOutputWNullChannelStringNLStringNLArbitraryAgain() {
300 $this->m->output( "", null );
301 $this->m->output( "foo", null );
302 $this->m->output( "", null );
303 $this->m->output( "\nb", null );
304 $this->m->output( "a", null );
305 $this->m->output( "", null );
306 $this->m->output( "r\n", null );
307 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
310 function testOutputWChannelString() {
311 $this->m->output( "foo", "bazChannel" );
312 $this->assertOutputPrePostShutdown( "foo", True );
315 function testOutputWChannelStringNL() {
316 $this->m->output( "foo\n", "bazChannel" );
317 $this->assertOutputPrePostShutdown( "foo", True );
320 function testOutputWChannelStringNLNL() {
321 // If this test fails, note that output takes strings with double line
322 // endings (although output's implementation in this situation calls
323 // outputChanneled with a string ending in a nl ... which is not allowed
324 // according to the documentation of outputChanneled)
325 $this->m->output( "foo\n\n", "bazChannel" );
326 $this->assertOutputPrePostShutdown( "foo\n", True );
329 function testOutputWChannelStringNLString() {
330 $this->m->output( "foo\nbar", "bazChannel" );
331 $this->assertOutputPrePostShutdown( "foo\nbar", True );
334 function testOutputWChannelStringNLStringNL() {
335 $this->m->output( "foo\nbar\n", "bazChannel" );
336 $this->assertOutputPrePostShutdown( "foo\nbar", True );
339 function testOutputWChannelStringNLStringNLLinewise() {
340 $this->m->output( "foo\n", "bazChannel" );
341 $this->m->output( "bar\n", "bazChannel" );
342 $this->assertOutputPrePostShutdown( "foobar", True );
345 function testOutputWChannelStringNLStringNLArbitrary() {
346 $this->m->output( "", "bazChannel" );
347 $this->m->output( "foo", "bazChannel" );
348 $this->m->output( "", "bazChannel" );
349 $this->m->output( "\n", "bazChannel" );
350 $this->m->output( "ba", "bazChannel" );
351 $this->m->output( "", "bazChannel" );
352 $this->m->output( "r\n", "bazChannel" );
353 $this->assertOutputPrePostShutdown( "foobar", True );
356 function testOutputWChannelStringNLStringNLArbitraryAgain() {
357 $this->m->output( "", "bazChannel" );
358 $this->m->output( "foo", "bazChannel" );
359 $this->m->output( "", "bazChannel" );
360 $this->m->output( "\nb", "bazChannel" );
361 $this->m->output( "a", "bazChannel" );
362 $this->m->output( "", "bazChannel" );
363 $this->m->output( "r\n", "bazChannel" );
364 $this->assertOutputPrePostShutdown( "foo\nbar", True );
367 function testOutputWMultipleChannelsChannelChange() {
368 $this->m->output( "foo", "bazChannel" );
369 $this->m->output( "bar", "bazChannel" );
370 $this->m->output( "qux", "quuxChannel" );
371 $this->m->output( "corge", "bazChannel" );
372 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", True );
375 function testOutputWMultipleChannelsChannelChangeNL() {
376 $this->m->output( "foo", "bazChannel" );
377 $this->m->output( "bar\n", "bazChannel" );
378 $this->m->output( "qux\n", "quuxChannel" );
379 $this->m->output( "corge", "bazChannel" );
380 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", True );
383 function testOutputWAndWOChannelStringStartWO() {
384 $this->m->output( "foo" );
385 $this->m->output( "bar", "bazChannel" );
386 $this->m->output( "qux" );
387 $this->m->output( "quux", "bazChannel" );
388 $this->assertOutputPrePostShutdown( "foobar\nquxquux", True );
391 function testOutputWAndWOChannelStringStartW() {
392 $this->m->output( "foo", "bazChannel" );
393 $this->m->output( "bar" );
394 $this->m->output( "qux", "bazChannel" );
395 $this->m->output( "quux" );
396 $this->assertOutputPrePostShutdown( "foo\nbarqux\nquux", False );
399 function testOutputWChannelTypeSwitch() {
400 $this->m->output( "foo", 1 );
401 $this->m->output( "bar", 1.0 );
402 $this->assertOutputPrePostShutdown( "foo\nbar", True );
405 function testOutputIntermittentEmpty() {
406 $this->m->output( "foo" );
407 $this->m->output( "" );
408 $this->m->output( "bar" );
409 $this->assertOutputPrePostShutdown( "foobar", False );
412 function testOutputIntermittentFalse() {
413 $this->m->output( "foo" );
414 $this->m->output( false );
415 $this->m->output( "bar" );
416 $this->assertOutputPrePostShutdown( "foobar", False );
419 function testOutputIntermittentFalseAfterOtherChannel() {
420 $this->m->output( "qux", "quuxChannel" );
421 $this->m->output( "foo" );
422 $this->m->output( false );
423 $this->m->output( "bar" );
424 $this->assertOutputPrePostShutdown( "qux\nfoobar", False );
427 function testOutputWNullChannelIntermittentEmpty() {
428 $this->m->output( "foo", null );
429 $this->m->output( "", null );
430 $this->m->output( "bar", null );
431 $this->assertOutputPrePostShutdown( "foobar", False );
434 function testOutputWNullChannelIntermittentFalse() {
435 $this->m->output( "foo", null );
436 $this->m->output( false, null );
437 $this->m->output( "bar", null );
438 $this->assertOutputPrePostShutdown( "foobar", False );
441 function testOutputWChannelIntermittentEmpty() {
442 $this->m->output( "foo", "bazChannel" );
443 $this->m->output( "", "bazChannel" );
444 $this->m->output( "bar", "bazChannel" );
445 $this->assertOutputPrePostShutdown( "foobar", True );
448 function testOutputWChannelIntermittentFalse() {
449 $this->m->output( "foo", "bazChannel" );
450 $this->m->output( false, "bazChannel" );
451 $this->m->output( "bar", "bazChannel" );
452 $this->assertOutputPrePostShutdown( "foobar", True );
455 // Note that (per documentation) outputChanneled does take strings that end
456 // in \n, hence we do not test such strings.
458 function testOutputChanneledEmpty() {
459 $this->m->outputChanneled( "" );
460 $this->assertOutputPrePostShutdown( "\n", False );
463 function testOutputChanneledString() {
464 $this->m->outputChanneled( "foo" );
465 $this->assertOutputPrePostShutdown( "foo\n", False );
468 function testOutputChanneledStringString() {
469 $this->m->outputChanneled( "foo" );
470 $this->m->outputChanneled( "bar" );
471 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
474 function testOutputChanneledStringNLString() {
475 $this->m->outputChanneled( "foo\nbar" );
476 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
479 function testOutputChanneledStringNLStringNLArbitraryAgain() {
480 $this->m->outputChanneled( "" );
481 $this->m->outputChanneled( "foo" );
482 $this->m->outputChanneled( "" );
483 $this->m->outputChanneled( "\nb" );
484 $this->m->outputChanneled( "a" );
485 $this->m->outputChanneled( "" );
486 $this->m->outputChanneled( "r" );
487 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", False );
490 function testOutputChanneledWNullChannelEmpty() {
491 $this->m->outputChanneled( "", null );
492 $this->assertOutputPrePostShutdown( "\n", False );
495 function testOutputChanneledWNullChannelString() {
496 $this->m->outputChanneled( "foo", null );
497 $this->assertOutputPrePostShutdown( "foo\n", False );
500 function testOutputChanneledWNullChannelStringString() {
501 $this->m->outputChanneled( "foo", null );
502 $this->m->outputChanneled( "bar", null );
503 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
506 function testOutputChanneledWNullChannelStringNLString() {
507 $this->m->outputChanneled( "foo\nbar", null );
508 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
511 function testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain() {
512 $this->m->outputChanneled( "", null );
513 $this->m->outputChanneled( "foo", null );
514 $this->m->outputChanneled( "", null );
515 $this->m->outputChanneled( "\nb", null );
516 $this->m->outputChanneled( "a", null );
517 $this->m->outputChanneled( "", null );
518 $this->m->outputChanneled( "r", null );
519 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", False );
522 function testOutputChanneledWChannelString() {
523 $this->m->outputChanneled( "foo", "bazChannel" );
524 $this->assertOutputPrePostShutdown( "foo", True );
527 function testOutputChanneledWChannelStringNLString() {
528 $this->m->outputChanneled( "foo\nbar", "bazChannel" );
529 $this->assertOutputPrePostShutdown( "foo\nbar", True );
532 function testOutputChanneledWChannelStringString() {
533 $this->m->outputChanneled( "foo", "bazChannel" );
534 $this->m->outputChanneled( "bar", "bazChannel" );
535 $this->assertOutputPrePostShutdown( "foobar", True );
538 function testOutputChanneledWChannelStringNLStringNLArbitraryAgain() {
539 $this->m->outputChanneled( "", "bazChannel" );
540 $this->m->outputChanneled( "foo", "bazChannel" );
541 $this->m->outputChanneled( "", "bazChannel" );
542 $this->m->outputChanneled( "\nb", "bazChannel" );
543 $this->m->outputChanneled( "a", "bazChannel" );
544 $this->m->outputChanneled( "", "bazChannel" );
545 $this->m->outputChanneled( "r", "bazChannel" );
546 $this->assertOutputPrePostShutdown( "foo\nbar", True );
549 function testOutputChanneledWMultipleChannelsChannelChange() {
550 $this->m->outputChanneled( "foo", "bazChannel" );
551 $this->m->outputChanneled( "bar", "bazChannel" );
552 $this->m->outputChanneled( "qux", "quuxChannel" );
553 $this->m->outputChanneled( "corge", "bazChannel" );
554 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", True );
557 function testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull() {
558 $this->m->outputChanneled( "foo", "bazChannel" );
559 $this->m->outputChanneled( "bar", null );
560 $this->m->outputChanneled( "qux", null );
561 $this->m->outputChanneled( "corge", "bazChannel" );
562 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", True );
565 function testOutputChanneledWMultipleChannelsChannelAfterNullChange() {
566 $this->m->outputChanneled( "foo", "bazChannel" );
567 $this->m->outputChanneled( "bar", null );
568 $this->m->outputChanneled( "qux", null );
569 $this->m->outputChanneled( "corge", "quuxChannel" );
570 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", True );
573 function testOutputChanneledWAndWOChannelStringStartWO() {
574 $this->m->outputChanneled( "foo" );
575 $this->m->outputChanneled( "bar", "bazChannel" );
576 $this->m->outputChanneled( "qux" );
577 $this->m->outputChanneled( "quux", "bazChannel" );
578 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux", True );
581 function testOutputChanneledWAndWOChannelStringStartW() {
582 $this->m->outputChanneled( "foo", "bazChannel" );
583 $this->m->outputChanneled( "bar" );
584 $this->m->outputChanneled( "qux", "bazChannel" );
585 $this->m->outputChanneled( "quux" );
586 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux\n", False );
589 function testOutputChanneledWChannelTypeSwitch() {
590 $this->m->outputChanneled( "foo", 1 );
591 $this->m->outputChanneled( "bar", 1.0 );
592 $this->assertOutputPrePostShutdown( "foo\nbar", True );
595 function testOutputChanneledWOChannelIntermittentEmpty() {
596 $this->m->outputChanneled( "foo" );
597 $this->m->outputChanneled( "" );
598 $this->m->outputChanneled( "bar" );
599 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", False );
602 function testOutputChanneledWOChannelIntermittentFalse() {
603 $this->m->outputChanneled( "foo" );
604 $this->m->outputChanneled( false );
605 $this->m->outputChanneled( "bar" );
606 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
609 function testOutputChanneledWNullChannelIntermittentEmpty() {
610 $this->m->outputChanneled( "foo", null );
611 $this->m->outputChanneled( "", null );
612 $this->m->outputChanneled( "bar", null );
613 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", False );
616 function testOutputChanneledWNullChannelIntermittentFalse() {
617 $this->m->outputChanneled( "foo", null );
618 $this->m->outputChanneled( false, null );
619 $this->m->outputChanneled( "bar", null );
620 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
623 function testOutputChanneledWChannelIntermittentEmpty() {
624 $this->m->outputChanneled( "foo", "bazChannel" );
625 $this->m->outputChanneled( "", "bazChannel" );
626 $this->m->outputChanneled( "bar", "bazChannel" );
627 $this->assertOutputPrePostShutdown( "foobar", True );
630 function testOutputChanneledWChannelIntermittentFalse() {
631 $this->m->outputChanneled( "foo", "bazChannel" );
632 $this->m->outputChanneled( false, "bazChannel" );
633 $this->m->outputChanneled( "bar", "bazChannel" );
634 $this->assertOutputPrePostShutdown( "foo\nbar", True );
637 function testCleanupChanneledClean() {
638 $this->m->cleanupChanneled();
639 $this->assertOutputPrePostShutdown( "", False );
642 function testCleanupChanneledAfterOutput() {
643 $this->m->output( "foo" );
644 $this->m->cleanupChanneled();
645 $this->assertOutputPrePostShutdown( "foo", False );
648 function testCleanupChanneledAfterOutputWNullChannel() {
649 $this->m->output( "foo", null );
650 $this->m->cleanupChanneled();
651 $this->assertOutputPrePostShutdown( "foo", False );
654 function testCleanupChanneledAfterOutputWChannel() {
655 $this->m->output( "foo", "bazChannel" );
656 $this->m->cleanupChanneled();
657 $this->assertOutputPrePostShutdown( "foo\n", False );
660 function testCleanupChanneledAfterNLOutput() {
661 $this->m->output( "foo\n" );
662 $this->m->cleanupChanneled();
663 $this->assertOutputPrePostShutdown( "foo\n", False );
666 function testCleanupChanneledAfterNLOutputWNullChannel() {
667 $this->m->output( "foo\n", null );
668 $this->m->cleanupChanneled();
669 $this->assertOutputPrePostShutdown( "foo\n", False );
672 function testCleanupChanneledAfterNLOutputWChannel() {
673 $this->m->output( "foo\n", "bazChannel" );
674 $this->m->cleanupChanneled();
675 $this->assertOutputPrePostShutdown( "foo\n", False );
678 function testCleanupChanneledAfterOutputChanneledWOChannel() {
679 $this->m->outputChanneled( "foo" );
680 $this->m->cleanupChanneled();
681 $this->assertOutputPrePostShutdown( "foo\n", False );
684 function testCleanupChanneledAfterOutputChanneledWNullChannel() {
685 $this->m->outputChanneled( "foo", null );
686 $this->m->cleanupChanneled();
687 $this->assertOutputPrePostShutdown( "foo\n", False );
690 function testCleanupChanneledAfterOutputChanneledWChannel() {
691 $this->m->outputChanneled( "foo", "bazChannel" );
692 $this->m->cleanupChanneled();
693 $this->assertOutputPrePostShutdown( "foo\n", False );
696 function testMultipleMaintenanceObjectsInteractionOutput() {
697 $m2 = new MaintenanceFixup( $this );
699 $this->m->output( "foo" );
700 $m2->output( "bar" );
702 $this->assertEquals( "foobar", $this->getActualOutput(),
703 "Output before shutdown simulation (m2)" );
704 $m2->simulateShutdown();
705 $this->assertOutputPrePostShutdown( "foobar", False );
708 function testMultipleMaintenanceObjectsInteractionOutputWNullChannel() {
709 $m2 = new MaintenanceFixup( $this );
711 $this->m->output( "foo", null );
712 $m2->output( "bar", null );
714 $this->assertEquals( "foobar", $this->getActualOutput(),
715 "Output before shutdown simulation (m2)" );
716 $m2->simulateShutdown();
717 $this->assertOutputPrePostShutdown( "foobar", False );
720 function testMultipleMaintenanceObjectsInteractionOutputWChannel() {
721 $m2 = new MaintenanceFixup( $this );
723 $this->m->output( "foo", "bazChannel" );
724 $m2->output( "bar", "bazChannel" );
726 $this->assertEquals( "foobar", $this->getActualOutput(),
727 "Output before shutdown simulation (m2)" );
728 $m2->simulateShutdown();
729 $this->assertOutputPrePostShutdown( "foobar\n", True );
732 function testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL() {
733 $m2 = new MaintenanceFixup( $this );
735 $this->m->output( "foo\n", null );
736 $m2->output( "bar\n", null );
738 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
739 "Output before shutdown simulation (m2)" );
740 $m2->simulateShutdown();
741 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
744 function testMultipleMaintenanceObjectsInteractionOutputWChannelNL() {
745 $m2 = new MaintenanceFixup( $this );
747 $this->m->output( "foo\n", "bazChannel" );
748 $m2->output( "bar\n", "bazChannel" );
750 $this->assertEquals( "foobar", $this->getActualOutput(),
751 "Output before shutdown simulation (m2)" );
752 $m2->simulateShutdown();
753 $this->assertOutputPrePostShutdown( "foobar\n", True );
756 function testMultipleMaintenanceObjectsInteractionOutputChanneled() {
757 $m2 = new MaintenanceFixup( $this );
759 $this->m->outputChanneled( "foo" );
760 $m2->outputChanneled( "bar" );
762 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
763 "Output before shutdown simulation (m2)" );
764 $m2->simulateShutdown();
765 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
768 function testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel() {
769 $m2 = new MaintenanceFixup( $this );
771 $this->m->outputChanneled( "foo", null );
772 $m2->outputChanneled( "bar", null );
774 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
775 "Output before shutdown simulation (m2)" );
776 $m2->simulateShutdown();
777 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
780 function testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel() {
781 $m2 = new MaintenanceFixup( $this );
783 $this->m->outputChanneled( "foo", "bazChannel" );
784 $m2->outputChanneled( "bar", "bazChannel" );
786 $this->assertEquals( "foobar", $this->getActualOutput(),
787 "Output before shutdown simulation (m2)" );
788 $m2->simulateShutdown();
789 $this->assertOutputPrePostShutdown( "foobar\n", True );
792 function testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel() {
793 $m2 = new MaintenanceFixup( $this );
795 $this->m->outputChanneled( "foo", "bazChannel" );
796 $m2->outputChanneled( "bar", "bazChannel" );
798 $this->assertEquals( "foobar", $this->getActualOutput(),
799 "Output before first cleanup" );
800 $this->m->cleanupChanneled();
801 $this->assertEquals( "foobar\n", $this->getActualOutput(),
802 "Output after first cleanup" );
803 $m2->cleanupChanneled();
804 $this->assertEquals( "foobar\n\n", $this->getActualOutput(),
805 "Output after second cleanup" );
807 $m2->simulateShutdown();
808 $this->assertOutputPrePostShutdown( "foobar\n\n", False );