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