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