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