Merge "(bug 38024) Skip styles for modules that don't have stylesheets"
[lhc/web/wiklou.git] / tests / phpunit / maintenance / MaintenanceTest.php
1 <?php
2
3 // It would be great if we were able to use PHPUnit's getMockForAbstractClass
4 // instead of the MaintenanceFixup hack below. However, we cannot do
5 // without changing the visibility and without working around hacks in
6 // Maintenance.php
7 //
8 // For the same reason, we cannot just use FakeMaintenance.
9
10 /**
11 * makes parts of the API of Maintenance that is hidden by protected visibily
12 * visible for testing, and makes up for a stream closing hack in Maintenance.php.
13 *
14 * This class is solely used for being able to test Maintenance right now
15 * without having to apply major refactorings to fix some design issues in
16 * Maintenance.php. Before adding more functions here, please consider whether
17 * this approach is correct, or a refactoring Maintenance to separate concers
18 * is more appropriate.
19 *
20 * Upon refactoring, keep in mind that besides the maintenance scrits themselves
21 * and tests right here, also at least Extension:Maintenance make use of
22 * Maintenance.
23 *
24 * Due to a hack in Maintenance.php using register_shutdown_function, be sure to
25 * finally call simulateShutdown on MaintenanceFixup instance before a test
26 * ends.
27 *
28 */
29 class MaintenanceFixup extends Maintenance {
30
31 // --- Making up for the register_shutdown_function hack in Maintenance.php
32
33 /**
34 * The test case that generated this instance.
35 *
36 * This member is motivated by allowing the destructor to check whether or not
37 * the test failed, in order to avoid unnecessary nags about omitted shutdown
38 * simulation.
39 * But as it is already available, we also usi it to flagging tests as failed
40 *
41 * @var MediaWikiTestCase
42 */
43 private $testCase;
44
45 /**
46 * shutdownSimulated === true iff simulateShutdown has done it's work
47 *
48 * @var bool
49 */
50 private $shutdownSimulated = false;
51
52 /**
53 * Simulates what Maintenance wants to happen at script's end.
54 */
55 public function simulateShutdown() {
56
57 if ( $this->shutdownSimulated ) {
58 $this->testCase->fail( __METHOD__ . " called more than once" );
59 }
60
61 // The cleanup action.
62 $this->outputChanneled( false );
63
64 // Bookkeeping that we simulated the clean up.
65 $this->shutdownSimulated = true;
66 }
67
68 // Note that the "public" here does not change visibility
69 public function outputChanneled( $msg, $channel = null ) {
70 if ( $this->shutdownSimulated ) {
71 if ( $msg !== false ) {
72 $this->testCase->fail( "Already past simulated shutdown, but msg is "
73 . "not false. Did the hack in Maintenance.php change? Please "
74 . "adapt the test case or Maintenance.php" );
75 }
76
77 // The current call is the one registered via register_shutdown_function.
78 // We can safely ignore it, as we simulated this one via simulateShutdown
79 // before (if we did not, the destructor of this instance will warn about
80 // it)
81 return;
82 }
83
84 return call_user_func_array ( array( "parent", __FUNCTION__ ), func_get_args() );
85 }
86
87 /**
88 * Safety net around register_shutdown_function of Maintenance.php
89 */
90 public function __destruct() {
91 if ( ( ! $this->shutdownSimulated ) && ( ! $this->testCase->hasFailed() ) ) {
92 // Someone generated a MaintenanceFixup instance without calling
93 // simulateShutdown. We'd have to raise a PHPUnit exception to correctly
94 // flag this illegal usage. However, we are already in a destruktor, which
95 // would trigger undefined behaviour. Hence, we can only report to the
96 // error output :( Hopefully people read the PHPUnit output.
97 fwrite( STDERR, "ERROR! Instance of " . __CLASS__ . " destructed without "
98 . "calling simulateShutdown method. Call simulateShutdown on the "
99 . "instance before it gets destructed." );
100 }
101
102 // The following guard is required, as PHP does not offer default destructors :(
103 if ( is_callable( "parent::__destruct" ) ) {
104 parent::__destruct();
105 }
106 }
107
108 public function __construct( MediaWikiTestCase $testCase ) {
109 parent::__construct();
110 $this->testCase = $testCase;
111 }
112
113
114
115 // --- Making protected functions visible for test
116
117 public function output( $out, $channel = null ) {
118 // Just to make PHP not nag about signature mismatches, we copied
119 // Maintenance::output signature. However, we do not use (or rely on)
120 // those variables. Instead we pass to Maintenance::output whatever we
121 // receive at runtime.
122 return call_user_func_array ( array( "parent", __FUNCTION__ ), func_get_args() );
123 }
124
125
126
127 // --- Requirements for getting instance of abstract class
128
129 public function execute() {
130 $this->testCase->fail( __METHOD__ . " called unexpectedly" );
131 }
132
133 }
134
135 class MaintenanceTest extends MediaWikiTestCase {
136
137
138 /**
139 * The main Maintenance instance that is used for testing.
140 *
141 * @var MaintenanceFixup
142 */
143 private $m;
144
145
146 protected function setUp() {
147 parent::setUp();
148 $this->m = new MaintenanceFixup( $this );
149 }
150
151
152 /**
153 * asserts the output before and after simulating shutdown
154 *
155 * This function simulates shutdown of self::m.
156 *
157 * @param $preShutdownOutput string: expected output before simulating shutdown
158 * @param $expectNLAppending bool: Whether or not shutdown simulation is expected
159 * to add a newline to the output. If false, $preShutdownOutput is the
160 * expected output after shutdown simulation. Otherwise,
161 * $preShutdownOutput with an appended newline is the expected output
162 * after shutdown simulation.
163 */
164 private function assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending ) {
165
166 $this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
167 "Output before shutdown simulation" );
168
169 $this->m->simulateShutdown();
170
171 $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ? "\n" : "" );
172 $this->expectOutputString( $postShutdownOutput );
173 }
174
175
176 // Although the following tests do not seem to be too consistent (compare for
177 // example the newlines within the test.*StringString tests, or the
178 // test.*Intermittent.* tests), the objective of these tests is not to describe
179 // consistent behaviour, but rather currently existing behaviour.
180
181
182 function testOutputEmpty() {
183 $this->m->output( "" );
184 $this->assertOutputPrePostShutdown( "", False );
185 }
186
187 function testOutputString() {
188 $this->m->output( "foo" );
189 $this->assertOutputPrePostShutdown( "foo", False );
190 }
191
192 function testOutputStringString() {
193 $this->m->output( "foo" );
194 $this->m->output( "bar" );
195 $this->assertOutputPrePostShutdown( "foobar", False );
196 }
197
198 function testOutputStringNL() {
199 $this->m->output( "foo\n" );
200 $this->assertOutputPrePostShutdown( "foo\n", False );
201 }
202
203 function testOutputStringNLNL() {
204 $this->m->output( "foo\n\n" );
205 $this->assertOutputPrePostShutdown( "foo\n\n", False );
206 }
207
208 function testOutputStringNLString() {
209 $this->m->output( "foo\nbar" );
210 $this->assertOutputPrePostShutdown( "foo\nbar", False );
211 }
212
213 function testOutputStringNLStringNL() {
214 $this->m->output( "foo\nbar\n" );
215 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
216 }
217
218 function testOutputStringNLStringNLLinewise() {
219 $this->m->output( "foo\n" );
220 $this->m->output( "bar\n" );
221 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
222 }
223
224 function testOutputStringNLStringNLArbitrary() {
225 $this->m->output( "" );
226 $this->m->output( "foo" );
227 $this->m->output( "" );
228 $this->m->output( "\n" );
229 $this->m->output( "ba" );
230 $this->m->output( "" );
231 $this->m->output( "r\n" );
232 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
233 }
234
235 function testOutputStringNLStringNLArbitraryAgain() {
236 $this->m->output( "" );
237 $this->m->output( "foo" );
238 $this->m->output( "" );
239 $this->m->output( "\nb" );
240 $this->m->output( "a" );
241 $this->m->output( "" );
242 $this->m->output( "r\n" );
243 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
244 }
245
246 function testOutputWNullChannelEmpty() {
247 $this->m->output( "", null );
248 $this->assertOutputPrePostShutdown( "", False );
249 }
250
251 function testOutputWNullChannelString() {
252 $this->m->output( "foo", null );
253 $this->assertOutputPrePostShutdown( "foo", False );
254 }
255
256 function testOutputWNullChannelStringString() {
257 $this->m->output( "foo", null );
258 $this->m->output( "bar", null );
259 $this->assertOutputPrePostShutdown( "foobar", False );
260 }
261
262 function testOutputWNullChannelStringNL() {
263 $this->m->output( "foo\n", null );
264 $this->assertOutputPrePostShutdown( "foo\n", False );
265 }
266
267 function testOutputWNullChannelStringNLNL() {
268 $this->m->output( "foo\n\n", null );
269 $this->assertOutputPrePostShutdown( "foo\n\n", False );
270 }
271
272 function testOutputWNullChannelStringNLString() {
273 $this->m->output( "foo\nbar", null );
274 $this->assertOutputPrePostShutdown( "foo\nbar", False );
275 }
276
277 function testOutputWNullChannelStringNLStringNL() {
278 $this->m->output( "foo\nbar\n", null );
279 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
280 }
281
282 function testOutputWNullChannelStringNLStringNLLinewise() {
283 $this->m->output( "foo\n", null );
284 $this->m->output( "bar\n", null );
285 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
286 }
287
288 function testOutputWNullChannelStringNLStringNLArbitrary() {
289 $this->m->output( "", null );
290 $this->m->output( "foo", null );
291 $this->m->output( "", null );
292 $this->m->output( "\n", null );
293 $this->m->output( "ba", null );
294 $this->m->output( "", null );
295 $this->m->output( "r\n", null );
296 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
297 }
298
299 function testOutputWNullChannelStringNLStringNLArbitraryAgain() {
300 $this->m->output( "", null );
301 $this->m->output( "foo", null );
302 $this->m->output( "", null );
303 $this->m->output( "\nb", null );
304 $this->m->output( "a", null );
305 $this->m->output( "", null );
306 $this->m->output( "r\n", null );
307 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
308 }
309
310 function testOutputWChannelString() {
311 $this->m->output( "foo", "bazChannel" );
312 $this->assertOutputPrePostShutdown( "foo", True );
313 }
314
315 function testOutputWChannelStringNL() {
316 $this->m->output( "foo\n", "bazChannel" );
317 $this->assertOutputPrePostShutdown( "foo", True );
318 }
319
320 function testOutputWChannelStringNLNL() {
321 // If this test fails, note that output takes strings with double line
322 // endings (although output's implementation in this situation calls
323 // outputChanneled with a string ending in a nl ... which is not allowed
324 // according to the documentation of outputChanneled)
325 $this->m->output( "foo\n\n", "bazChannel" );
326 $this->assertOutputPrePostShutdown( "foo\n", True );
327 }
328
329 function testOutputWChannelStringNLString() {
330 $this->m->output( "foo\nbar", "bazChannel" );
331 $this->assertOutputPrePostShutdown( "foo\nbar", True );
332 }
333
334 function testOutputWChannelStringNLStringNL() {
335 $this->m->output( "foo\nbar\n", "bazChannel" );
336 $this->assertOutputPrePostShutdown( "foo\nbar", True );
337 }
338
339 function testOutputWChannelStringNLStringNLLinewise() {
340 $this->m->output( "foo\n", "bazChannel" );
341 $this->m->output( "bar\n", "bazChannel" );
342 $this->assertOutputPrePostShutdown( "foobar", True );
343 }
344
345 function testOutputWChannelStringNLStringNLArbitrary() {
346 $this->m->output( "", "bazChannel" );
347 $this->m->output( "foo", "bazChannel" );
348 $this->m->output( "", "bazChannel" );
349 $this->m->output( "\n", "bazChannel" );
350 $this->m->output( "ba", "bazChannel" );
351 $this->m->output( "", "bazChannel" );
352 $this->m->output( "r\n", "bazChannel" );
353 $this->assertOutputPrePostShutdown( "foobar", True );
354 }
355
356 function testOutputWChannelStringNLStringNLArbitraryAgain() {
357 $this->m->output( "", "bazChannel" );
358 $this->m->output( "foo", "bazChannel" );
359 $this->m->output( "", "bazChannel" );
360 $this->m->output( "\nb", "bazChannel" );
361 $this->m->output( "a", "bazChannel" );
362 $this->m->output( "", "bazChannel" );
363 $this->m->output( "r\n", "bazChannel" );
364 $this->assertOutputPrePostShutdown( "foo\nbar", True );
365 }
366
367 function testOutputWMultipleChannelsChannelChange() {
368 $this->m->output( "foo", "bazChannel" );
369 $this->m->output( "bar", "bazChannel" );
370 $this->m->output( "qux", "quuxChannel" );
371 $this->m->output( "corge", "bazChannel" );
372 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", True );
373 }
374
375 function testOutputWMultipleChannelsChannelChangeNL() {
376 $this->m->output( "foo", "bazChannel" );
377 $this->m->output( "bar\n", "bazChannel" );
378 $this->m->output( "qux\n", "quuxChannel" );
379 $this->m->output( "corge", "bazChannel" );
380 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", True );
381 }
382
383 function testOutputWAndWOChannelStringStartWO() {
384 $this->m->output( "foo" );
385 $this->m->output( "bar", "bazChannel" );
386 $this->m->output( "qux" );
387 $this->m->output( "quux", "bazChannel" );
388 $this->assertOutputPrePostShutdown( "foobar\nquxquux", True );
389 }
390
391 function testOutputWAndWOChannelStringStartW() {
392 $this->m->output( "foo", "bazChannel" );
393 $this->m->output( "bar" );
394 $this->m->output( "qux", "bazChannel" );
395 $this->m->output( "quux" );
396 $this->assertOutputPrePostShutdown( "foo\nbarqux\nquux", False );
397 }
398
399 function testOutputWChannelTypeSwitch() {
400 $this->m->output( "foo", 1 );
401 $this->m->output( "bar", 1.0 );
402 $this->assertOutputPrePostShutdown( "foo\nbar", True );
403 }
404
405 function testOutputIntermittentEmpty() {
406 $this->m->output( "foo" );
407 $this->m->output( "" );
408 $this->m->output( "bar" );
409 $this->assertOutputPrePostShutdown( "foobar", False );
410 }
411
412 function testOutputIntermittentFalse() {
413 $this->m->output( "foo" );
414 $this->m->output( false );
415 $this->m->output( "bar" );
416 $this->assertOutputPrePostShutdown( "foobar", False );
417 }
418
419 function testOutputIntermittentFalseAfterOtherChannel() {
420 $this->m->output( "qux", "quuxChannel" );
421 $this->m->output( "foo" );
422 $this->m->output( false );
423 $this->m->output( "bar" );
424 $this->assertOutputPrePostShutdown( "qux\nfoobar", False );
425 }
426
427 function testOutputWNullChannelIntermittentEmpty() {
428 $this->m->output( "foo", null );
429 $this->m->output( "", null );
430 $this->m->output( "bar", null );
431 $this->assertOutputPrePostShutdown( "foobar", False );
432 }
433
434 function testOutputWNullChannelIntermittentFalse() {
435 $this->m->output( "foo", null );
436 $this->m->output( false, null );
437 $this->m->output( "bar", null );
438 $this->assertOutputPrePostShutdown( "foobar", False );
439 }
440
441 function testOutputWChannelIntermittentEmpty() {
442 $this->m->output( "foo", "bazChannel" );
443 $this->m->output( "", "bazChannel" );
444 $this->m->output( "bar", "bazChannel" );
445 $this->assertOutputPrePostShutdown( "foobar", True );
446 }
447
448 function testOutputWChannelIntermittentFalse() {
449 $this->m->output( "foo", "bazChannel" );
450 $this->m->output( false, "bazChannel" );
451 $this->m->output( "bar", "bazChannel" );
452 $this->assertOutputPrePostShutdown( "foobar", True );
453 }
454
455 // Note that (per documentation) outputChanneled does take strings that end
456 // in \n, hence we do not test such strings.
457
458 function testOutputChanneledEmpty() {
459 $this->m->outputChanneled( "" );
460 $this->assertOutputPrePostShutdown( "\n", False );
461 }
462
463 function testOutputChanneledString() {
464 $this->m->outputChanneled( "foo" );
465 $this->assertOutputPrePostShutdown( "foo\n", False );
466 }
467
468 function testOutputChanneledStringString() {
469 $this->m->outputChanneled( "foo" );
470 $this->m->outputChanneled( "bar" );
471 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
472 }
473
474 function testOutputChanneledStringNLString() {
475 $this->m->outputChanneled( "foo\nbar" );
476 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
477 }
478
479 function testOutputChanneledStringNLStringNLArbitraryAgain() {
480 $this->m->outputChanneled( "" );
481 $this->m->outputChanneled( "foo" );
482 $this->m->outputChanneled( "" );
483 $this->m->outputChanneled( "\nb" );
484 $this->m->outputChanneled( "a" );
485 $this->m->outputChanneled( "" );
486 $this->m->outputChanneled( "r" );
487 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", False );
488 }
489
490 function testOutputChanneledWNullChannelEmpty() {
491 $this->m->outputChanneled( "", null );
492 $this->assertOutputPrePostShutdown( "\n", False );
493 }
494
495 function testOutputChanneledWNullChannelString() {
496 $this->m->outputChanneled( "foo", null );
497 $this->assertOutputPrePostShutdown( "foo\n", False );
498 }
499
500 function testOutputChanneledWNullChannelStringString() {
501 $this->m->outputChanneled( "foo", null );
502 $this->m->outputChanneled( "bar", null );
503 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
504 }
505
506 function testOutputChanneledWNullChannelStringNLString() {
507 $this->m->outputChanneled( "foo\nbar", null );
508 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
509 }
510
511 function testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain() {
512 $this->m->outputChanneled( "", null );
513 $this->m->outputChanneled( "foo", null );
514 $this->m->outputChanneled( "", null );
515 $this->m->outputChanneled( "\nb", null );
516 $this->m->outputChanneled( "a", null );
517 $this->m->outputChanneled( "", null );
518 $this->m->outputChanneled( "r", null );
519 $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", False );
520 }
521
522 function testOutputChanneledWChannelString() {
523 $this->m->outputChanneled( "foo", "bazChannel" );
524 $this->assertOutputPrePostShutdown( "foo", True );
525 }
526
527 function testOutputChanneledWChannelStringNLString() {
528 $this->m->outputChanneled( "foo\nbar", "bazChannel" );
529 $this->assertOutputPrePostShutdown( "foo\nbar", True );
530 }
531
532 function testOutputChanneledWChannelStringString() {
533 $this->m->outputChanneled( "foo", "bazChannel" );
534 $this->m->outputChanneled( "bar", "bazChannel" );
535 $this->assertOutputPrePostShutdown( "foobar", True );
536 }
537
538 function testOutputChanneledWChannelStringNLStringNLArbitraryAgain() {
539 $this->m->outputChanneled( "", "bazChannel" );
540 $this->m->outputChanneled( "foo", "bazChannel" );
541 $this->m->outputChanneled( "", "bazChannel" );
542 $this->m->outputChanneled( "\nb", "bazChannel" );
543 $this->m->outputChanneled( "a", "bazChannel" );
544 $this->m->outputChanneled( "", "bazChannel" );
545 $this->m->outputChanneled( "r", "bazChannel" );
546 $this->assertOutputPrePostShutdown( "foo\nbar", True );
547 }
548
549 function testOutputChanneledWMultipleChannelsChannelChange() {
550 $this->m->outputChanneled( "foo", "bazChannel" );
551 $this->m->outputChanneled( "bar", "bazChannel" );
552 $this->m->outputChanneled( "qux", "quuxChannel" );
553 $this->m->outputChanneled( "corge", "bazChannel" );
554 $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", True );
555 }
556
557 function testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull() {
558 $this->m->outputChanneled( "foo", "bazChannel" );
559 $this->m->outputChanneled( "bar", null );
560 $this->m->outputChanneled( "qux", null );
561 $this->m->outputChanneled( "corge", "bazChannel" );
562 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", True );
563 }
564
565 function testOutputChanneledWMultipleChannelsChannelAfterNullChange() {
566 $this->m->outputChanneled( "foo", "bazChannel" );
567 $this->m->outputChanneled( "bar", null );
568 $this->m->outputChanneled( "qux", null );
569 $this->m->outputChanneled( "corge", "quuxChannel" );
570 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", True );
571 }
572
573 function testOutputChanneledWAndWOChannelStringStartWO() {
574 $this->m->outputChanneled( "foo" );
575 $this->m->outputChanneled( "bar", "bazChannel" );
576 $this->m->outputChanneled( "qux" );
577 $this->m->outputChanneled( "quux", "bazChannel" );
578 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux", True );
579 }
580
581 function testOutputChanneledWAndWOChannelStringStartW() {
582 $this->m->outputChanneled( "foo", "bazChannel" );
583 $this->m->outputChanneled( "bar" );
584 $this->m->outputChanneled( "qux", "bazChannel" );
585 $this->m->outputChanneled( "quux" );
586 $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux\n", False );
587 }
588
589 function testOutputChanneledWChannelTypeSwitch() {
590 $this->m->outputChanneled( "foo", 1 );
591 $this->m->outputChanneled( "bar", 1.0 );
592 $this->assertOutputPrePostShutdown( "foo\nbar", True );
593 }
594
595 function testOutputChanneledWOChannelIntermittentEmpty() {
596 $this->m->outputChanneled( "foo" );
597 $this->m->outputChanneled( "" );
598 $this->m->outputChanneled( "bar" );
599 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", False );
600 }
601
602 function testOutputChanneledWOChannelIntermittentFalse() {
603 $this->m->outputChanneled( "foo" );
604 $this->m->outputChanneled( false );
605 $this->m->outputChanneled( "bar" );
606 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
607 }
608
609 function testOutputChanneledWNullChannelIntermittentEmpty() {
610 $this->m->outputChanneled( "foo", null );
611 $this->m->outputChanneled( "", null );
612 $this->m->outputChanneled( "bar", null );
613 $this->assertOutputPrePostShutdown( "foo\n\nbar\n", False );
614 }
615
616 function testOutputChanneledWNullChannelIntermittentFalse() {
617 $this->m->outputChanneled( "foo", null );
618 $this->m->outputChanneled( false, null );
619 $this->m->outputChanneled( "bar", null );
620 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
621 }
622
623 function testOutputChanneledWChannelIntermittentEmpty() {
624 $this->m->outputChanneled( "foo", "bazChannel" );
625 $this->m->outputChanneled( "", "bazChannel" );
626 $this->m->outputChanneled( "bar", "bazChannel" );
627 $this->assertOutputPrePostShutdown( "foobar", True );
628 }
629
630 function testOutputChanneledWChannelIntermittentFalse() {
631 $this->m->outputChanneled( "foo", "bazChannel" );
632 $this->m->outputChanneled( false, "bazChannel" );
633 $this->m->outputChanneled( "bar", "bazChannel" );
634 $this->assertOutputPrePostShutdown( "foo\nbar", True );
635 }
636
637 function testCleanupChanneledClean() {
638 $this->m->cleanupChanneled();
639 $this->assertOutputPrePostShutdown( "", False );
640 }
641
642 function testCleanupChanneledAfterOutput() {
643 $this->m->output( "foo" );
644 $this->m->cleanupChanneled();
645 $this->assertOutputPrePostShutdown( "foo", False );
646 }
647
648 function testCleanupChanneledAfterOutputWNullChannel() {
649 $this->m->output( "foo", null );
650 $this->m->cleanupChanneled();
651 $this->assertOutputPrePostShutdown( "foo", False );
652 }
653
654 function testCleanupChanneledAfterOutputWChannel() {
655 $this->m->output( "foo", "bazChannel" );
656 $this->m->cleanupChanneled();
657 $this->assertOutputPrePostShutdown( "foo\n", False );
658 }
659
660 function testCleanupChanneledAfterNLOutput() {
661 $this->m->output( "foo\n" );
662 $this->m->cleanupChanneled();
663 $this->assertOutputPrePostShutdown( "foo\n", False );
664 }
665
666 function testCleanupChanneledAfterNLOutputWNullChannel() {
667 $this->m->output( "foo\n", null );
668 $this->m->cleanupChanneled();
669 $this->assertOutputPrePostShutdown( "foo\n", False );
670 }
671
672 function testCleanupChanneledAfterNLOutputWChannel() {
673 $this->m->output( "foo\n", "bazChannel" );
674 $this->m->cleanupChanneled();
675 $this->assertOutputPrePostShutdown( "foo\n", False );
676 }
677
678 function testCleanupChanneledAfterOutputChanneledWOChannel() {
679 $this->m->outputChanneled( "foo" );
680 $this->m->cleanupChanneled();
681 $this->assertOutputPrePostShutdown( "foo\n", False );
682 }
683
684 function testCleanupChanneledAfterOutputChanneledWNullChannel() {
685 $this->m->outputChanneled( "foo", null );
686 $this->m->cleanupChanneled();
687 $this->assertOutputPrePostShutdown( "foo\n", False );
688 }
689
690 function testCleanupChanneledAfterOutputChanneledWChannel() {
691 $this->m->outputChanneled( "foo", "bazChannel" );
692 $this->m->cleanupChanneled();
693 $this->assertOutputPrePostShutdown( "foo\n", False );
694 }
695
696 function testMultipleMaintenanceObjectsInteractionOutput() {
697 $m2 = new MaintenanceFixup( $this );
698
699 $this->m->output( "foo" );
700 $m2->output( "bar" );
701
702 $this->assertEquals( "foobar", $this->getActualOutput(),
703 "Output before shutdown simulation (m2)" );
704 $m2->simulateShutdown();
705 $this->assertOutputPrePostShutdown( "foobar", False );
706 }
707
708 function testMultipleMaintenanceObjectsInteractionOutputWNullChannel() {
709 $m2 = new MaintenanceFixup( $this );
710
711 $this->m->output( "foo", null );
712 $m2->output( "bar", null );
713
714 $this->assertEquals( "foobar", $this->getActualOutput(),
715 "Output before shutdown simulation (m2)" );
716 $m2->simulateShutdown();
717 $this->assertOutputPrePostShutdown( "foobar", False );
718 }
719
720 function testMultipleMaintenanceObjectsInteractionOutputWChannel() {
721 $m2 = new MaintenanceFixup( $this );
722
723 $this->m->output( "foo", "bazChannel" );
724 $m2->output( "bar", "bazChannel" );
725
726 $this->assertEquals( "foobar", $this->getActualOutput(),
727 "Output before shutdown simulation (m2)" );
728 $m2->simulateShutdown();
729 $this->assertOutputPrePostShutdown( "foobar\n", True );
730 }
731
732 function testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL() {
733 $m2 = new MaintenanceFixup( $this );
734
735 $this->m->output( "foo\n", null );
736 $m2->output( "bar\n", null );
737
738 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
739 "Output before shutdown simulation (m2)" );
740 $m2->simulateShutdown();
741 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
742 }
743
744 function testMultipleMaintenanceObjectsInteractionOutputWChannelNL() {
745 $m2 = new MaintenanceFixup( $this );
746
747 $this->m->output( "foo\n", "bazChannel" );
748 $m2->output( "bar\n", "bazChannel" );
749
750 $this->assertEquals( "foobar", $this->getActualOutput(),
751 "Output before shutdown simulation (m2)" );
752 $m2->simulateShutdown();
753 $this->assertOutputPrePostShutdown( "foobar\n", True );
754 }
755
756 function testMultipleMaintenanceObjectsInteractionOutputChanneled() {
757 $m2 = new MaintenanceFixup( $this );
758
759 $this->m->outputChanneled( "foo" );
760 $m2->outputChanneled( "bar" );
761
762 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
763 "Output before shutdown simulation (m2)" );
764 $m2->simulateShutdown();
765 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
766 }
767
768 function testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel() {
769 $m2 = new MaintenanceFixup( $this );
770
771 $this->m->outputChanneled( "foo", null );
772 $m2->outputChanneled( "bar", null );
773
774 $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
775 "Output before shutdown simulation (m2)" );
776 $m2->simulateShutdown();
777 $this->assertOutputPrePostShutdown( "foo\nbar\n", False );
778 }
779
780 function testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel() {
781 $m2 = new MaintenanceFixup( $this );
782
783 $this->m->outputChanneled( "foo", "bazChannel" );
784 $m2->outputChanneled( "bar", "bazChannel" );
785
786 $this->assertEquals( "foobar", $this->getActualOutput(),
787 "Output before shutdown simulation (m2)" );
788 $m2->simulateShutdown();
789 $this->assertOutputPrePostShutdown( "foobar\n", True );
790 }
791
792 function testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel() {
793 $m2 = new MaintenanceFixup( $this );
794
795 $this->m->outputChanneled( "foo", "bazChannel" );
796 $m2->outputChanneled( "bar", "bazChannel" );
797
798 $this->assertEquals( "foobar", $this->getActualOutput(),
799 "Output before first cleanup" );
800 $this->m->cleanupChanneled();
801 $this->assertEquals( "foobar\n", $this->getActualOutput(),
802 "Output after first cleanup" );
803 $m2->cleanupChanneled();
804 $this->assertEquals( "foobar\n\n", $this->getActualOutput(),
805 "Output after second cleanup" );
806
807 $m2->simulateShutdown();
808 $this->assertOutputPrePostShutdown( "foobar\n\n", False );
809 }
810
811
812 }