MediaWiki  REL1_21
MaintenanceTest.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // It would be great if we were able to use PHPUnit's getMockForAbstractClass
00004 // instead of the MaintenanceFixup hack below. However, we cannot do
00005 // without changing the visibility and without working around hacks in
00006 // Maintenance.php
00007 //
00008 // For the same reason, we cannot just use FakeMaintenance.
00009 
00029 class MaintenanceFixup extends Maintenance {
00030 
00031         // --- Making up for the register_shutdown_function hack in Maintenance.php
00032 
00043         private $testCase;
00044 
00050         private $shutdownSimulated = false;
00051 
00055         public function simulateShutdown() {
00056 
00057                 if ( $this->shutdownSimulated ) {
00058                         $this->testCase->fail( __METHOD__ . " called more than once" );
00059                 }
00060 
00061                 // The cleanup action.
00062                 $this->outputChanneled( false );
00063 
00064                 // Bookkeeping that we simulated the clean up.
00065                 $this->shutdownSimulated = true;
00066         }
00067 
00068         // Note that the "public" here does not change visibility
00069         public function outputChanneled( $msg, $channel = null ) {
00070                 if ( $this->shutdownSimulated ) {
00071                         if ( $msg !== false ) {
00072                                 $this->testCase->fail( "Already past simulated shutdown, but msg is "
00073                                         . "not false. Did the hack in Maintenance.php change? Please "
00074                                         . "adapt the test case or Maintenance.php" );
00075                         }
00076 
00077                         // The current call is the one registered via register_shutdown_function.
00078                         // We can safely ignore it, as we simulated this one via simulateShutdown
00079                         // before (if we did not, the destructor of this instance will warn about
00080                         // it)
00081                         return;
00082                 }
00083 
00084                 return call_user_func_array( array( "parent", __FUNCTION__ ), func_get_args() );
00085         }
00086 
00090         public function __destruct() {
00091                 if ( !$this->shutdownSimulated ) {
00092                         // Someone generated a MaintenanceFixup instance without calling
00093                         // simulateShutdown. We'd have to raise a PHPUnit exception to correctly
00094                         // flag this illegal usage. However, we are already in a destruktor, which
00095                         // would trigger undefined behavior. Hence, we can only report to the
00096                         // error output :( Hopefully people read the PHPUnit output.
00097                         $name = $this->testCase->getName();
00098                         fwrite( STDERR, "ERROR! Instance of " . __CLASS__ . " for test $name "
00099                                 . "destructed without calling simulateShutdown method. Call "
00100                                 . "simulateShutdown on the instance before it gets destructed." );
00101                 }
00102 
00103                 // The following guard is required, as PHP does not offer default destructors :(
00104                 if ( is_callable( "parent::__destruct" ) ) {
00105                         parent::__destruct();
00106                 }
00107         }
00108 
00109         public function __construct( MediaWikiTestCase $testCase ) {
00110                 parent::__construct();
00111                 $this->testCase = $testCase;
00112         }
00113 
00114 
00115         // --- Making protected functions visible for test
00116 
00117         public function output( $out, $channel = null ) {
00118                 // Just to make PHP not nag about signature mismatches, we copied
00119                 // Maintenance::output signature. However, we do not use (or rely on)
00120                 // those variables. Instead we pass to Maintenance::output whatever we
00121                 // receive at runtime.
00122                 return call_user_func_array( array( "parent", __FUNCTION__ ), func_get_args() );
00123         }
00124 
00125 
00126         // --- Requirements for getting instance of abstract class
00127 
00128         public function execute() {
00129                 $this->testCase->fail( __METHOD__ . " called unexpectedly" );
00130         }
00131 
00132 }
00133 
00134 class MaintenanceTest extends MediaWikiTestCase {
00135 
00136 
00142         private $m;
00143 
00144 
00145         protected function setUp() {
00146                 parent::setUp();
00147                 $this->m = new MaintenanceFixup( $this );
00148         }
00149 
00150         protected function tearDown() {
00151                 if ( $this->m ) {
00152                         $this->m->simulateShutdown();
00153                         $this->m = null;
00154                 }
00155                 parent::tearDown();
00156         }
00157 
00158 
00171         private function assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending ) {
00172 
00173                 $this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
00174                         "Output before shutdown simulation" );
00175 
00176                 $this->m->simulateShutdown();
00177                 $this->m = null;
00178 
00179                 $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ? "\n" : "" );
00180                 $this->expectOutputString( $postShutdownOutput );
00181         }
00182 
00183 
00184         // Although the following tests do not seem to be too consistent (compare for
00185         // example the newlines within the test.*StringString tests, or the
00186         // test.*Intermittent.* tests), the objective of these tests is not to describe
00187         // consistent behavior, but rather currently existing behavior.
00188 
00189 
00190         function testOutputEmpty() {
00191                 $this->m->output( "" );
00192                 $this->assertOutputPrePostShutdown( "", false );
00193         }
00194 
00195         function testOutputString() {
00196                 $this->m->output( "foo" );
00197                 $this->assertOutputPrePostShutdown( "foo", false );
00198         }
00199 
00200         function testOutputStringString() {
00201                 $this->m->output( "foo" );
00202                 $this->m->output( "bar" );
00203                 $this->assertOutputPrePostShutdown( "foobar", false );
00204         }
00205 
00206         function testOutputStringNL() {
00207                 $this->m->output( "foo\n" );
00208                 $this->assertOutputPrePostShutdown( "foo\n", false );
00209         }
00210 
00211         function testOutputStringNLNL() {
00212                 $this->m->output( "foo\n\n" );
00213                 $this->assertOutputPrePostShutdown( "foo\n\n", false );
00214         }
00215 
00216         function testOutputStringNLString() {
00217                 $this->m->output( "foo\nbar" );
00218                 $this->assertOutputPrePostShutdown( "foo\nbar", false );
00219         }
00220 
00221         function testOutputStringNLStringNL() {
00222                 $this->m->output( "foo\nbar\n" );
00223                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00224         }
00225 
00226         function testOutputStringNLStringNLLinewise() {
00227                 $this->m->output( "foo\n" );
00228                 $this->m->output( "bar\n" );
00229                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00230         }
00231 
00232         function testOutputStringNLStringNLArbitrary() {
00233                 $this->m->output( "" );
00234                 $this->m->output( "foo" );
00235                 $this->m->output( "" );
00236                 $this->m->output( "\n" );
00237                 $this->m->output( "ba" );
00238                 $this->m->output( "" );
00239                 $this->m->output( "r\n" );
00240                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00241         }
00242 
00243         function testOutputStringNLStringNLArbitraryAgain() {
00244                 $this->m->output( "" );
00245                 $this->m->output( "foo" );
00246                 $this->m->output( "" );
00247                 $this->m->output( "\nb" );
00248                 $this->m->output( "a" );
00249                 $this->m->output( "" );
00250                 $this->m->output( "r\n" );
00251                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00252         }
00253 
00254         function testOutputWNullChannelEmpty() {
00255                 $this->m->output( "", null );
00256                 $this->assertOutputPrePostShutdown( "", false );
00257         }
00258 
00259         function testOutputWNullChannelString() {
00260                 $this->m->output( "foo", null );
00261                 $this->assertOutputPrePostShutdown( "foo", false );
00262         }
00263 
00264         function testOutputWNullChannelStringString() {
00265                 $this->m->output( "foo", null );
00266                 $this->m->output( "bar", null );
00267                 $this->assertOutputPrePostShutdown( "foobar", false );
00268         }
00269 
00270         function testOutputWNullChannelStringNL() {
00271                 $this->m->output( "foo\n", null );
00272                 $this->assertOutputPrePostShutdown( "foo\n", false );
00273         }
00274 
00275         function testOutputWNullChannelStringNLNL() {
00276                 $this->m->output( "foo\n\n", null );
00277                 $this->assertOutputPrePostShutdown( "foo\n\n", false );
00278         }
00279 
00280         function testOutputWNullChannelStringNLString() {
00281                 $this->m->output( "foo\nbar", null );
00282                 $this->assertOutputPrePostShutdown( "foo\nbar", false );
00283         }
00284 
00285         function testOutputWNullChannelStringNLStringNL() {
00286                 $this->m->output( "foo\nbar\n", null );
00287                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00288         }
00289 
00290         function testOutputWNullChannelStringNLStringNLLinewise() {
00291                 $this->m->output( "foo\n", null );
00292                 $this->m->output( "bar\n", null );
00293                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00294         }
00295 
00296         function testOutputWNullChannelStringNLStringNLArbitrary() {
00297                 $this->m->output( "", null );
00298                 $this->m->output( "foo", null );
00299                 $this->m->output( "", null );
00300                 $this->m->output( "\n", null );
00301                 $this->m->output( "ba", null );
00302                 $this->m->output( "", null );
00303                 $this->m->output( "r\n", null );
00304                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00305         }
00306 
00307         function testOutputWNullChannelStringNLStringNLArbitraryAgain() {
00308                 $this->m->output( "", null );
00309                 $this->m->output( "foo", null );
00310                 $this->m->output( "", null );
00311                 $this->m->output( "\nb", null );
00312                 $this->m->output( "a", null );
00313                 $this->m->output( "", null );
00314                 $this->m->output( "r\n", null );
00315                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00316         }
00317 
00318         function testOutputWChannelString() {
00319                 $this->m->output( "foo", "bazChannel" );
00320                 $this->assertOutputPrePostShutdown( "foo", true );
00321         }
00322 
00323         function testOutputWChannelStringNL() {
00324                 $this->m->output( "foo\n", "bazChannel" );
00325                 $this->assertOutputPrePostShutdown( "foo", true );
00326         }
00327 
00328         function testOutputWChannelStringNLNL() {
00329                 // If this test fails, note that output takes strings with double line
00330                 // endings (although output's implementation in this situation calls
00331                 // outputChanneled with a string ending in a nl ... which is not allowed
00332                 // according to the documentation of outputChanneled)
00333                 $this->m->output( "foo\n\n", "bazChannel" );
00334                 $this->assertOutputPrePostShutdown( "foo\n", true );
00335         }
00336 
00337         function testOutputWChannelStringNLString() {
00338                 $this->m->output( "foo\nbar", "bazChannel" );
00339                 $this->assertOutputPrePostShutdown( "foo\nbar", true );
00340         }
00341 
00342         function testOutputWChannelStringNLStringNL() {
00343                 $this->m->output( "foo\nbar\n", "bazChannel" );
00344                 $this->assertOutputPrePostShutdown( "foo\nbar", true );
00345         }
00346 
00347         function testOutputWChannelStringNLStringNLLinewise() {
00348                 $this->m->output( "foo\n", "bazChannel" );
00349                 $this->m->output( "bar\n", "bazChannel" );
00350                 $this->assertOutputPrePostShutdown( "foobar", true );
00351         }
00352 
00353         function testOutputWChannelStringNLStringNLArbitrary() {
00354                 $this->m->output( "", "bazChannel" );
00355                 $this->m->output( "foo", "bazChannel" );
00356                 $this->m->output( "", "bazChannel" );
00357                 $this->m->output( "\n", "bazChannel" );
00358                 $this->m->output( "ba", "bazChannel" );
00359                 $this->m->output( "", "bazChannel" );
00360                 $this->m->output( "r\n", "bazChannel" );
00361                 $this->assertOutputPrePostShutdown( "foobar", true );
00362         }
00363 
00364         function testOutputWChannelStringNLStringNLArbitraryAgain() {
00365                 $this->m->output( "", "bazChannel" );
00366                 $this->m->output( "foo", "bazChannel" );
00367                 $this->m->output( "", "bazChannel" );
00368                 $this->m->output( "\nb", "bazChannel" );
00369                 $this->m->output( "a", "bazChannel" );
00370                 $this->m->output( "", "bazChannel" );
00371                 $this->m->output( "r\n", "bazChannel" );
00372                 $this->assertOutputPrePostShutdown( "foo\nbar", true );
00373         }
00374 
00375         function testOutputWMultipleChannelsChannelChange() {
00376                 $this->m->output( "foo", "bazChannel" );
00377                 $this->m->output( "bar", "bazChannel" );
00378                 $this->m->output( "qux", "quuxChannel" );
00379                 $this->m->output( "corge", "bazChannel" );
00380                 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
00381         }
00382 
00383         function testOutputWMultipleChannelsChannelChangeNL() {
00384                 $this->m->output( "foo", "bazChannel" );
00385                 $this->m->output( "bar\n", "bazChannel" );
00386                 $this->m->output( "qux\n", "quuxChannel" );
00387                 $this->m->output( "corge", "bazChannel" );
00388                 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
00389         }
00390 
00391         function testOutputWAndWOChannelStringStartWO() {
00392                 $this->m->output( "foo" );
00393                 $this->m->output( "bar", "bazChannel" );
00394                 $this->m->output( "qux" );
00395                 $this->m->output( "quux", "bazChannel" );
00396                 $this->assertOutputPrePostShutdown( "foobar\nquxquux", true );
00397         }
00398 
00399         function testOutputWAndWOChannelStringStartW() {
00400                 $this->m->output( "foo", "bazChannel" );
00401                 $this->m->output( "bar" );
00402                 $this->m->output( "qux", "bazChannel" );
00403                 $this->m->output( "quux" );
00404                 $this->assertOutputPrePostShutdown( "foo\nbarqux\nquux", false );
00405         }
00406 
00407         function testOutputWChannelTypeSwitch() {
00408                 $this->m->output( "foo", 1 );
00409                 $this->m->output( "bar", 1.0 );
00410                 $this->assertOutputPrePostShutdown( "foo\nbar", true );
00411         }
00412 
00413         function testOutputIntermittentEmpty() {
00414                 $this->m->output( "foo" );
00415                 $this->m->output( "" );
00416                 $this->m->output( "bar" );
00417                 $this->assertOutputPrePostShutdown( "foobar", false );
00418         }
00419 
00420         function testOutputIntermittentFalse() {
00421                 $this->m->output( "foo" );
00422                 $this->m->output( false );
00423                 $this->m->output( "bar" );
00424                 $this->assertOutputPrePostShutdown( "foobar", false );
00425         }
00426 
00427         function testOutputIntermittentFalseAfterOtherChannel() {
00428                 $this->m->output( "qux", "quuxChannel" );
00429                 $this->m->output( "foo" );
00430                 $this->m->output( false );
00431                 $this->m->output( "bar" );
00432                 $this->assertOutputPrePostShutdown( "qux\nfoobar", false );
00433         }
00434 
00435         function testOutputWNullChannelIntermittentEmpty() {
00436                 $this->m->output( "foo", null );
00437                 $this->m->output( "", null );
00438                 $this->m->output( "bar", null );
00439                 $this->assertOutputPrePostShutdown( "foobar", false );
00440         }
00441 
00442         function testOutputWNullChannelIntermittentFalse() {
00443                 $this->m->output( "foo", null );
00444                 $this->m->output( false, null );
00445                 $this->m->output( "bar", null );
00446                 $this->assertOutputPrePostShutdown( "foobar", false );
00447         }
00448 
00449         function testOutputWChannelIntermittentEmpty() {
00450                 $this->m->output( "foo", "bazChannel" );
00451                 $this->m->output( "", "bazChannel" );
00452                 $this->m->output( "bar", "bazChannel" );
00453                 $this->assertOutputPrePostShutdown( "foobar", true );
00454         }
00455 
00456         function testOutputWChannelIntermittentFalse() {
00457                 $this->m->output( "foo", "bazChannel" );
00458                 $this->m->output( false, "bazChannel" );
00459                 $this->m->output( "bar", "bazChannel" );
00460                 $this->assertOutputPrePostShutdown( "foobar", true );
00461         }
00462 
00463         // Note that (per documentation) outputChanneled does take strings that end
00464         // in \n, hence we do not test such strings.
00465 
00466         function testOutputChanneledEmpty() {
00467                 $this->m->outputChanneled( "" );
00468                 $this->assertOutputPrePostShutdown( "\n", false );
00469         }
00470 
00471         function testOutputChanneledString() {
00472                 $this->m->outputChanneled( "foo" );
00473                 $this->assertOutputPrePostShutdown( "foo\n", false );
00474         }
00475 
00476         function testOutputChanneledStringString() {
00477                 $this->m->outputChanneled( "foo" );
00478                 $this->m->outputChanneled( "bar" );
00479                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00480         }
00481 
00482         function testOutputChanneledStringNLString() {
00483                 $this->m->outputChanneled( "foo\nbar" );
00484                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00485         }
00486 
00487         function testOutputChanneledStringNLStringNLArbitraryAgain() {
00488                 $this->m->outputChanneled( "" );
00489                 $this->m->outputChanneled( "foo" );
00490                 $this->m->outputChanneled( "" );
00491                 $this->m->outputChanneled( "\nb" );
00492                 $this->m->outputChanneled( "a" );
00493                 $this->m->outputChanneled( "" );
00494                 $this->m->outputChanneled( "r" );
00495                 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
00496         }
00497 
00498         function testOutputChanneledWNullChannelEmpty() {
00499                 $this->m->outputChanneled( "", null );
00500                 $this->assertOutputPrePostShutdown( "\n", false );
00501         }
00502 
00503         function testOutputChanneledWNullChannelString() {
00504                 $this->m->outputChanneled( "foo", null );
00505                 $this->assertOutputPrePostShutdown( "foo\n", false );
00506         }
00507 
00508         function testOutputChanneledWNullChannelStringString() {
00509                 $this->m->outputChanneled( "foo", null );
00510                 $this->m->outputChanneled( "bar", null );
00511                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00512         }
00513 
00514         function testOutputChanneledWNullChannelStringNLString() {
00515                 $this->m->outputChanneled( "foo\nbar", null );
00516                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00517         }
00518 
00519         function testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain() {
00520                 $this->m->outputChanneled( "", null );
00521                 $this->m->outputChanneled( "foo", null );
00522                 $this->m->outputChanneled( "", null );
00523                 $this->m->outputChanneled( "\nb", null );
00524                 $this->m->outputChanneled( "a", null );
00525                 $this->m->outputChanneled( "", null );
00526                 $this->m->outputChanneled( "r", null );
00527                 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
00528         }
00529 
00530         function testOutputChanneledWChannelString() {
00531                 $this->m->outputChanneled( "foo", "bazChannel" );
00532                 $this->assertOutputPrePostShutdown( "foo", true );
00533         }
00534 
00535         function testOutputChanneledWChannelStringNLString() {
00536                 $this->m->outputChanneled( "foo\nbar", "bazChannel" );
00537                 $this->assertOutputPrePostShutdown( "foo\nbar", true );
00538         }
00539 
00540         function testOutputChanneledWChannelStringString() {
00541                 $this->m->outputChanneled( "foo", "bazChannel" );
00542                 $this->m->outputChanneled( "bar", "bazChannel" );
00543                 $this->assertOutputPrePostShutdown( "foobar", true );
00544         }
00545 
00546         function testOutputChanneledWChannelStringNLStringNLArbitraryAgain() {
00547                 $this->m->outputChanneled( "", "bazChannel" );
00548                 $this->m->outputChanneled( "foo", "bazChannel" );
00549                 $this->m->outputChanneled( "", "bazChannel" );
00550                 $this->m->outputChanneled( "\nb", "bazChannel" );
00551                 $this->m->outputChanneled( "a", "bazChannel" );
00552                 $this->m->outputChanneled( "", "bazChannel" );
00553                 $this->m->outputChanneled( "r", "bazChannel" );
00554                 $this->assertOutputPrePostShutdown( "foo\nbar", true );
00555         }
00556 
00557         function testOutputChanneledWMultipleChannelsChannelChange() {
00558                 $this->m->outputChanneled( "foo", "bazChannel" );
00559                 $this->m->outputChanneled( "bar", "bazChannel" );
00560                 $this->m->outputChanneled( "qux", "quuxChannel" );
00561                 $this->m->outputChanneled( "corge", "bazChannel" );
00562                 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
00563         }
00564 
00565         function testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull() {
00566                 $this->m->outputChanneled( "foo", "bazChannel" );
00567                 $this->m->outputChanneled( "bar", null );
00568                 $this->m->outputChanneled( "qux", null );
00569                 $this->m->outputChanneled( "corge", "bazChannel" );
00570                 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
00571         }
00572 
00573         function testOutputChanneledWMultipleChannelsChannelAfterNullChange() {
00574                 $this->m->outputChanneled( "foo", "bazChannel" );
00575                 $this->m->outputChanneled( "bar", null );
00576                 $this->m->outputChanneled( "qux", null );
00577                 $this->m->outputChanneled( "corge", "quuxChannel" );
00578                 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
00579         }
00580 
00581         function testOutputChanneledWAndWOChannelStringStartWO() {
00582                 $this->m->outputChanneled( "foo" );
00583                 $this->m->outputChanneled( "bar", "bazChannel" );
00584                 $this->m->outputChanneled( "qux" );
00585                 $this->m->outputChanneled( "quux", "bazChannel" );
00586                 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux", true );
00587         }
00588 
00589         function testOutputChanneledWAndWOChannelStringStartW() {
00590                 $this->m->outputChanneled( "foo", "bazChannel" );
00591                 $this->m->outputChanneled( "bar" );
00592                 $this->m->outputChanneled( "qux", "bazChannel" );
00593                 $this->m->outputChanneled( "quux" );
00594                 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux\n", false );
00595         }
00596 
00597         function testOutputChanneledWChannelTypeSwitch() {
00598                 $this->m->outputChanneled( "foo", 1 );
00599                 $this->m->outputChanneled( "bar", 1.0 );
00600                 $this->assertOutputPrePostShutdown( "foo\nbar", true );
00601         }
00602 
00603         function testOutputChanneledWOChannelIntermittentEmpty() {
00604                 $this->m->outputChanneled( "foo" );
00605                 $this->m->outputChanneled( "" );
00606                 $this->m->outputChanneled( "bar" );
00607                 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
00608         }
00609 
00610         function testOutputChanneledWOChannelIntermittentFalse() {
00611                 $this->m->outputChanneled( "foo" );
00612                 $this->m->outputChanneled( false );
00613                 $this->m->outputChanneled( "bar" );
00614                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00615         }
00616 
00617         function testOutputChanneledWNullChannelIntermittentEmpty() {
00618                 $this->m->outputChanneled( "foo", null );
00619                 $this->m->outputChanneled( "", null );
00620                 $this->m->outputChanneled( "bar", null );
00621                 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
00622         }
00623 
00624         function testOutputChanneledWNullChannelIntermittentFalse() {
00625                 $this->m->outputChanneled( "foo", null );
00626                 $this->m->outputChanneled( false, null );
00627                 $this->m->outputChanneled( "bar", null );
00628                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00629         }
00630 
00631         function testOutputChanneledWChannelIntermittentEmpty() {
00632                 $this->m->outputChanneled( "foo", "bazChannel" );
00633                 $this->m->outputChanneled( "", "bazChannel" );
00634                 $this->m->outputChanneled( "bar", "bazChannel" );
00635                 $this->assertOutputPrePostShutdown( "foobar", true );
00636         }
00637 
00638         function testOutputChanneledWChannelIntermittentFalse() {
00639                 $this->m->outputChanneled( "foo", "bazChannel" );
00640                 $this->m->outputChanneled( false, "bazChannel" );
00641                 $this->m->outputChanneled( "bar", "bazChannel" );
00642                 $this->assertOutputPrePostShutdown( "foo\nbar", true );
00643         }
00644 
00645         function testCleanupChanneledClean() {
00646                 $this->m->cleanupChanneled();
00647                 $this->assertOutputPrePostShutdown( "", false );
00648         }
00649 
00650         function testCleanupChanneledAfterOutput() {
00651                 $this->m->output( "foo" );
00652                 $this->m->cleanupChanneled();
00653                 $this->assertOutputPrePostShutdown( "foo", false );
00654         }
00655 
00656         function testCleanupChanneledAfterOutputWNullChannel() {
00657                 $this->m->output( "foo", null );
00658                 $this->m->cleanupChanneled();
00659                 $this->assertOutputPrePostShutdown( "foo", false );
00660         }
00661 
00662         function testCleanupChanneledAfterOutputWChannel() {
00663                 $this->m->output( "foo", "bazChannel" );
00664                 $this->m->cleanupChanneled();
00665                 $this->assertOutputPrePostShutdown( "foo\n", false );
00666         }
00667 
00668         function testCleanupChanneledAfterNLOutput() {
00669                 $this->m->output( "foo\n" );
00670                 $this->m->cleanupChanneled();
00671                 $this->assertOutputPrePostShutdown( "foo\n", false );
00672         }
00673 
00674         function testCleanupChanneledAfterNLOutputWNullChannel() {
00675                 $this->m->output( "foo\n", null );
00676                 $this->m->cleanupChanneled();
00677                 $this->assertOutputPrePostShutdown( "foo\n", false );
00678         }
00679 
00680         function testCleanupChanneledAfterNLOutputWChannel() {
00681                 $this->m->output( "foo\n", "bazChannel" );
00682                 $this->m->cleanupChanneled();
00683                 $this->assertOutputPrePostShutdown( "foo\n", false );
00684         }
00685 
00686         function testCleanupChanneledAfterOutputChanneledWOChannel() {
00687                 $this->m->outputChanneled( "foo" );
00688                 $this->m->cleanupChanneled();
00689                 $this->assertOutputPrePostShutdown( "foo\n", false );
00690         }
00691 
00692         function testCleanupChanneledAfterOutputChanneledWNullChannel() {
00693                 $this->m->outputChanneled( "foo", null );
00694                 $this->m->cleanupChanneled();
00695                 $this->assertOutputPrePostShutdown( "foo\n", false );
00696         }
00697 
00698         function testCleanupChanneledAfterOutputChanneledWChannel() {
00699                 $this->m->outputChanneled( "foo", "bazChannel" );
00700                 $this->m->cleanupChanneled();
00701                 $this->assertOutputPrePostShutdown( "foo\n", false );
00702         }
00703 
00704         function testMultipleMaintenanceObjectsInteractionOutput() {
00705                 $m2 = new MaintenanceFixup( $this );
00706 
00707                 $this->m->output( "foo" );
00708                 $m2->output( "bar" );
00709 
00710                 $this->assertEquals( "foobar", $this->getActualOutput(),
00711                         "Output before shutdown simulation (m2)" );
00712                 $m2->simulateShutdown();
00713                 $this->assertOutputPrePostShutdown( "foobar", false );
00714         }
00715 
00716         function testMultipleMaintenanceObjectsInteractionOutputWNullChannel() {
00717                 $m2 = new MaintenanceFixup( $this );
00718 
00719                 $this->m->output( "foo", null );
00720                 $m2->output( "bar", null );
00721 
00722                 $this->assertEquals( "foobar", $this->getActualOutput(),
00723                         "Output before shutdown simulation (m2)" );
00724                 $m2->simulateShutdown();
00725                 $this->assertOutputPrePostShutdown( "foobar", false );
00726         }
00727 
00728         function testMultipleMaintenanceObjectsInteractionOutputWChannel() {
00729                 $m2 = new MaintenanceFixup( $this );
00730 
00731                 $this->m->output( "foo", "bazChannel" );
00732                 $m2->output( "bar", "bazChannel" );
00733 
00734                 $this->assertEquals( "foobar", $this->getActualOutput(),
00735                         "Output before shutdown simulation (m2)" );
00736                 $m2->simulateShutdown();
00737                 $this->assertOutputPrePostShutdown( "foobar\n", true );
00738         }
00739 
00740         function testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL() {
00741                 $m2 = new MaintenanceFixup( $this );
00742 
00743                 $this->m->output( "foo\n", null );
00744                 $m2->output( "bar\n", null );
00745 
00746                 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
00747                         "Output before shutdown simulation (m2)" );
00748                 $m2->simulateShutdown();
00749                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00750         }
00751 
00752         function testMultipleMaintenanceObjectsInteractionOutputWChannelNL() {
00753                 $m2 = new MaintenanceFixup( $this );
00754 
00755                 $this->m->output( "foo\n", "bazChannel" );
00756                 $m2->output( "bar\n", "bazChannel" );
00757 
00758                 $this->assertEquals( "foobar", $this->getActualOutput(),
00759                         "Output before shutdown simulation (m2)" );
00760                 $m2->simulateShutdown();
00761                 $this->assertOutputPrePostShutdown( "foobar\n", true );
00762         }
00763 
00764         function testMultipleMaintenanceObjectsInteractionOutputChanneled() {
00765                 $m2 = new MaintenanceFixup( $this );
00766 
00767                 $this->m->outputChanneled( "foo" );
00768                 $m2->outputChanneled( "bar" );
00769 
00770                 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
00771                         "Output before shutdown simulation (m2)" );
00772                 $m2->simulateShutdown();
00773                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00774         }
00775 
00776         function testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel() {
00777                 $m2 = new MaintenanceFixup( $this );
00778 
00779                 $this->m->outputChanneled( "foo", null );
00780                 $m2->outputChanneled( "bar", null );
00781 
00782                 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
00783                         "Output before shutdown simulation (m2)" );
00784                 $m2->simulateShutdown();
00785                 $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
00786         }
00787 
00788         function testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel() {
00789                 $m2 = new MaintenanceFixup( $this );
00790 
00791                 $this->m->outputChanneled( "foo", "bazChannel" );
00792                 $m2->outputChanneled( "bar", "bazChannel" );
00793 
00794                 $this->assertEquals( "foobar", $this->getActualOutput(),
00795                         "Output before shutdown simulation (m2)" );
00796                 $m2->simulateShutdown();
00797                 $this->assertOutputPrePostShutdown( "foobar\n", true );
00798         }
00799 
00800         function testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel() {
00801                 $m2 = new MaintenanceFixup( $this );
00802 
00803                 $this->m->outputChanneled( "foo", "bazChannel" );
00804                 $m2->outputChanneled( "bar", "bazChannel" );
00805 
00806                 $this->assertEquals( "foobar", $this->getActualOutput(),
00807                         "Output before first cleanup" );
00808                 $this->m->cleanupChanneled();
00809                 $this->assertEquals( "foobar\n", $this->getActualOutput(),
00810                         "Output after first cleanup" );
00811                 $m2->cleanupChanneled();
00812                 $this->assertEquals( "foobar\n\n", $this->getActualOutput(),
00813                         "Output after second cleanup" );
00814 
00815                 $m2->simulateShutdown();
00816                 $this->assertOutputPrePostShutdown( "foobar\n\n", false );
00817         }
00818 
00819 
00820 }