57 if ( $this->shutdownSimulated ) {
58 $this->testCase->fail( __METHOD__ .
" called more than once" );
65 $this->shutdownSimulated =
true;
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" );
84 return call_user_func_array(
array(
"parent", __FUNCTION__ ), func_get_args() );
91 if ( !$this->shutdownSimulated ) {
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." );
104 if ( is_callable(
"parent::__destruct" ) ) {
105 parent::__destruct();
110 parent::__construct();
116 public function output(
$out, $channel =
null ) {
121 return call_user_func_array(
array(
"parent", __FUNCTION__ ), func_get_args() );
127 $this->testCase->fail( __METHOD__ .
" called unexpectedly" );
143 protected function setUp() {
150 $this->m->simulateShutdown();
170 $this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
171 "Output before shutdown simulation" );
173 $this->m->simulateShutdown();
176 $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ?
"\n" :
"" );
177 $this->expectOutputString( $postShutdownOutput );
186 $this->m->output(
"" );
191 $this->m->output(
"foo" );
196 $this->m->output(
"foo" );
197 $this->m->output(
"bar" );
202 $this->m->output(
"foo\n" );
207 $this->m->output(
"foo\n\n" );
212 $this->m->output(
"foo\nbar" );
217 $this->m->output(
"foo\nbar\n" );
222 $this->m->output(
"foo\n" );
223 $this->m->output(
"bar\n" );
228 $this->m->output(
"" );
229 $this->m->output(
"foo" );
230 $this->m->output(
"" );
231 $this->m->output(
"\n" );
232 $this->m->output(
"ba" );
233 $this->m->output(
"" );
234 $this->m->output(
"r\n" );
239 $this->m->output(
"" );
240 $this->m->output(
"foo" );
241 $this->m->output(
"" );
242 $this->m->output(
"\nb" );
243 $this->m->output(
"a" );
244 $this->m->output(
"" );
245 $this->m->output(
"r\n" );
250 $this->m->output(
"",
null );
255 $this->m->output(
"foo",
null );
260 $this->m->output(
"foo",
null );
261 $this->m->output(
"bar",
null );
266 $this->m->output(
"foo\n",
null );
271 $this->m->output(
"foo\n\n",
null );
276 $this->m->output(
"foo\nbar",
null );
281 $this->m->output(
"foo\nbar\n",
null );
286 $this->m->output(
"foo\n",
null );
287 $this->m->output(
"bar\n",
null );
292 $this->m->output(
"",
null );
293 $this->m->output(
"foo",
null );
294 $this->m->output(
"",
null );
295 $this->m->output(
"\n",
null );
296 $this->m->output(
"ba",
null );
297 $this->m->output(
"",
null );
298 $this->m->output(
"r\n",
null );
303 $this->m->output(
"",
null );
304 $this->m->output(
"foo",
null );
305 $this->m->output(
"",
null );
306 $this->m->output(
"\nb",
null );
307 $this->m->output(
"a",
null );
308 $this->m->output(
"",
null );
309 $this->m->output(
"r\n",
null );
314 $this->m->output(
"foo",
"bazChannel" );
319 $this->m->output(
"foo\n",
"bazChannel" );
328 $this->m->output(
"foo\n\n",
"bazChannel" );
333 $this->m->output(
"foo\nbar",
"bazChannel" );
338 $this->m->output(
"foo\nbar\n",
"bazChannel" );
343 $this->m->output(
"foo\n",
"bazChannel" );
344 $this->m->output(
"bar\n",
"bazChannel" );
349 $this->m->output(
"",
"bazChannel" );
350 $this->m->output(
"foo",
"bazChannel" );
351 $this->m->output(
"",
"bazChannel" );
352 $this->m->output(
"\n",
"bazChannel" );
353 $this->m->output(
"ba",
"bazChannel" );
354 $this->m->output(
"",
"bazChannel" );
355 $this->m->output(
"r\n",
"bazChannel" );
360 $this->m->output(
"",
"bazChannel" );
361 $this->m->output(
"foo",
"bazChannel" );
362 $this->m->output(
"",
"bazChannel" );
363 $this->m->output(
"\nb",
"bazChannel" );
364 $this->m->output(
"a",
"bazChannel" );
365 $this->m->output(
"",
"bazChannel" );
366 $this->m->output(
"r\n",
"bazChannel" );
371 $this->m->output(
"foo",
"bazChannel" );
372 $this->m->output(
"bar",
"bazChannel" );
373 $this->m->output(
"qux",
"quuxChannel" );
374 $this->m->output(
"corge",
"bazChannel" );
379 $this->m->output(
"foo",
"bazChannel" );
380 $this->m->output(
"bar\n",
"bazChannel" );
381 $this->m->output(
"qux\n",
"quuxChannel" );
382 $this->m->output(
"corge",
"bazChannel" );
387 $this->m->output(
"foo" );
388 $this->m->output(
"bar",
"bazChannel" );
389 $this->m->output(
"qux" );
390 $this->m->output(
"quux",
"bazChannel" );
395 $this->m->output(
"foo",
"bazChannel" );
396 $this->m->output(
"bar" );
397 $this->m->output(
"qux",
"bazChannel" );
398 $this->m->output(
"quux" );
403 $this->m->output(
"foo", 1 );
404 $this->m->output(
"bar", 1.0 );
409 $this->m->output(
"foo" );
410 $this->m->output(
"" );
411 $this->m->output(
"bar" );
416 $this->m->output(
"foo" );
417 $this->m->output(
false );
418 $this->m->output(
"bar" );
423 $this->m->output(
"qux",
"quuxChannel" );
424 $this->m->output(
"foo" );
425 $this->m->output(
false );
426 $this->m->output(
"bar" );
431 $this->m->output(
"foo",
null );
432 $this->m->output(
"",
null );
433 $this->m->output(
"bar",
null );
438 $this->m->output(
"foo",
null );
439 $this->m->output(
false,
null );
440 $this->m->output(
"bar",
null );
445 $this->m->output(
"foo",
"bazChannel" );
446 $this->m->output(
"",
"bazChannel" );
447 $this->m->output(
"bar",
"bazChannel" );
452 $this->m->output(
"foo",
"bazChannel" );
453 $this->m->output(
false,
"bazChannel" );
454 $this->m->output(
"bar",
"bazChannel" );
462 $this->m->outputChanneled(
"" );
467 $this->m->outputChanneled(
"foo" );
472 $this->m->outputChanneled(
"foo" );
473 $this->m->outputChanneled(
"bar" );
478 $this->m->outputChanneled(
"foo\nbar" );
483 $this->m->outputChanneled(
"" );
484 $this->m->outputChanneled(
"foo" );
485 $this->m->outputChanneled(
"" );
486 $this->m->outputChanneled(
"\nb" );
487 $this->m->outputChanneled(
"a" );
488 $this->m->outputChanneled(
"" );
489 $this->m->outputChanneled(
"r" );
494 $this->m->outputChanneled(
"",
null );
499 $this->m->outputChanneled(
"foo",
null );
504 $this->m->outputChanneled(
"foo",
null );
505 $this->m->outputChanneled(
"bar",
null );
510 $this->m->outputChanneled(
"foo\nbar",
null );
515 $this->m->outputChanneled(
"",
null );
516 $this->m->outputChanneled(
"foo",
null );
517 $this->m->outputChanneled(
"",
null );
518 $this->m->outputChanneled(
"\nb",
null );
519 $this->m->outputChanneled(
"a",
null );
520 $this->m->outputChanneled(
"",
null );
521 $this->m->outputChanneled(
"r",
null );
526 $this->m->outputChanneled(
"foo",
"bazChannel" );
531 $this->m->outputChanneled(
"foo\nbar",
"bazChannel" );
536 $this->m->outputChanneled(
"foo",
"bazChannel" );
537 $this->m->outputChanneled(
"bar",
"bazChannel" );
542 $this->m->outputChanneled(
"",
"bazChannel" );
543 $this->m->outputChanneled(
"foo",
"bazChannel" );
544 $this->m->outputChanneled(
"",
"bazChannel" );
545 $this->m->outputChanneled(
"\nb",
"bazChannel" );
546 $this->m->outputChanneled(
"a",
"bazChannel" );
547 $this->m->outputChanneled(
"",
"bazChannel" );
548 $this->m->outputChanneled(
"r",
"bazChannel" );
553 $this->m->outputChanneled(
"foo",
"bazChannel" );
554 $this->m->outputChanneled(
"bar",
"bazChannel" );
555 $this->m->outputChanneled(
"qux",
"quuxChannel" );
556 $this->m->outputChanneled(
"corge",
"bazChannel" );
561 $this->m->outputChanneled(
"foo",
"bazChannel" );
562 $this->m->outputChanneled(
"bar",
null );
563 $this->m->outputChanneled(
"qux",
null );
564 $this->m->outputChanneled(
"corge",
"bazChannel" );
569 $this->m->outputChanneled(
"foo",
"bazChannel" );
570 $this->m->outputChanneled(
"bar",
null );
571 $this->m->outputChanneled(
"qux",
null );
572 $this->m->outputChanneled(
"corge",
"quuxChannel" );
577 $this->m->outputChanneled(
"foo" );
578 $this->m->outputChanneled(
"bar",
"bazChannel" );
579 $this->m->outputChanneled(
"qux" );
580 $this->m->outputChanneled(
"quux",
"bazChannel" );
585 $this->m->outputChanneled(
"foo",
"bazChannel" );
586 $this->m->outputChanneled(
"bar" );
587 $this->m->outputChanneled(
"qux",
"bazChannel" );
588 $this->m->outputChanneled(
"quux" );
593 $this->m->outputChanneled(
"foo", 1 );
594 $this->m->outputChanneled(
"bar", 1.0 );
599 $this->m->outputChanneled(
"foo" );
600 $this->m->outputChanneled(
"" );
601 $this->m->outputChanneled(
"bar" );
606 $this->m->outputChanneled(
"foo" );
607 $this->m->outputChanneled(
false );
608 $this->m->outputChanneled(
"bar" );
613 $this->m->outputChanneled(
"foo",
null );
614 $this->m->outputChanneled(
"",
null );
615 $this->m->outputChanneled(
"bar",
null );
620 $this->m->outputChanneled(
"foo",
null );
621 $this->m->outputChanneled(
false,
null );
622 $this->m->outputChanneled(
"bar",
null );
627 $this->m->outputChanneled(
"foo",
"bazChannel" );
628 $this->m->outputChanneled(
"",
"bazChannel" );
629 $this->m->outputChanneled(
"bar",
"bazChannel" );
634 $this->m->outputChanneled(
"foo",
"bazChannel" );
635 $this->m->outputChanneled(
false,
"bazChannel" );
636 $this->m->outputChanneled(
"bar",
"bazChannel" );
641 $this->m->cleanupChanneled();
646 $this->m->output(
"foo" );
647 $this->m->cleanupChanneled();
652 $this->m->output(
"foo",
null );
653 $this->m->cleanupChanneled();
658 $this->m->output(
"foo",
"bazChannel" );
659 $this->m->cleanupChanneled();
664 $this->m->output(
"foo\n" );
665 $this->m->cleanupChanneled();
670 $this->m->output(
"foo\n",
null );
671 $this->m->cleanupChanneled();
676 $this->m->output(
"foo\n",
"bazChannel" );
677 $this->m->cleanupChanneled();
682 $this->m->outputChanneled(
"foo" );
683 $this->m->cleanupChanneled();
688 $this->m->outputChanneled(
"foo",
null );
689 $this->m->cleanupChanneled();
694 $this->m->outputChanneled(
"foo",
"bazChannel" );
695 $this->m->cleanupChanneled();
702 $this->m->output(
"foo" );
703 $m2->output(
"bar" );
705 $this->assertEquals(
"foobar", $this->getActualOutput(),
706 "Output before shutdown simulation (m2)" );
707 $m2->simulateShutdown();
714 $this->m->output(
"foo",
null );
715 $m2->output(
"bar",
null );
717 $this->assertEquals(
"foobar", $this->getActualOutput(),
718 "Output before shutdown simulation (m2)" );
719 $m2->simulateShutdown();
726 $this->m->output(
"foo",
"bazChannel" );
727 $m2->output(
"bar",
"bazChannel" );
729 $this->assertEquals(
"foobar", $this->getActualOutput(),
730 "Output before shutdown simulation (m2)" );
731 $m2->simulateShutdown();
738 $this->m->output(
"foo\n",
null );
739 $m2->output(
"bar\n",
null );
741 $this->assertEquals(
"foo\nbar\n", $this->getActualOutput(),
742 "Output before shutdown simulation (m2)" );
743 $m2->simulateShutdown();
750 $this->m->output(
"foo\n",
"bazChannel" );
751 $m2->output(
"bar\n",
"bazChannel" );
753 $this->assertEquals(
"foobar", $this->getActualOutput(),
754 "Output before shutdown simulation (m2)" );
755 $m2->simulateShutdown();
762 $this->m->outputChanneled(
"foo" );
763 $m2->outputChanneled(
"bar" );
765 $this->assertEquals(
"foo\nbar\n", $this->getActualOutput(),
766 "Output before shutdown simulation (m2)" );
767 $m2->simulateShutdown();
774 $this->m->outputChanneled(
"foo",
null );
775 $m2->outputChanneled(
"bar",
null );
777 $this->assertEquals(
"foo\nbar\n", $this->getActualOutput(),
778 "Output before shutdown simulation (m2)" );
779 $m2->simulateShutdown();
786 $this->m->outputChanneled(
"foo",
"bazChannel" );
787 $m2->outputChanneled(
"bar",
"bazChannel" );
789 $this->assertEquals(
"foobar", $this->getActualOutput(),
790 "Output before shutdown simulation (m2)" );
791 $m2->simulateShutdown();
798 $this->m->outputChanneled(
"foo",
"bazChannel" );
799 $m2->outputChanneled(
"bar",
"bazChannel" );
801 $this->assertEquals(
"foobar", $this->getActualOutput(),
802 "Output before first cleanup" );
803 $this->m->cleanupChanneled();
804 $this->assertEquals(
"foobar\n", $this->getActualOutput(),
805 "Output after first cleanup" );
806 $m2->cleanupChanneled();
807 $this->assertEquals(
"foobar\n\n", $this->getActualOutput(),
808 "Output after second cleanup" );
810 $m2->simulateShutdown();