MediaWiki  1.23.12
MaintenanceTest.php
Go to the documentation of this file.
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 
30 
31  // --- Making up for the register_shutdown_function hack in Maintenance.php
32 
43  private $testCase;
44 
50  private $shutdownSimulated = false;
51 
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 
90  public function __destruct() {
91  if ( !$this->shutdownSimulated ) {
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 behavior. Hence, we can only report to the
96  // error output :( Hopefully people read the PHPUnit output.
97  $name = $this->testCase->getName();
98  fwrite( STDERR, "ERROR! Instance of " . __CLASS__ . " for test $name "
99  . "destructed without calling simulateShutdown method. Call "
100  . "simulateShutdown on the instance before it gets destructed." );
101  }
102 
103  // The following guard is required, as PHP does not offer default destructors :(
104  if ( is_callable( "parent::__destruct" ) ) {
105  parent::__destruct();
106  }
107  }
108 
109  public function __construct( MediaWikiTestCase $testCase ) {
110  parent::__construct();
111  $this->testCase = $testCase;
112  }
113 
114  // --- Making protected functions visible for test
115 
116  public function output( $out, $channel = null ) {
117  // Just to make PHP not nag about signature mismatches, we copied
118  // Maintenance::output signature. However, we do not use (or rely on)
119  // those variables. Instead we pass to Maintenance::output whatever we
120  // receive at runtime.
121  return call_user_func_array( array( "parent", __FUNCTION__ ), func_get_args() );
122  }
123 
124  // --- Requirements for getting instance of abstract class
125 
126  public function execute() {
127  $this->testCase->fail( __METHOD__ . " called unexpectedly" );
128  }
129 }
130 
134 class MaintenanceTest extends MediaWikiTestCase {
135 
141  private $m;
142 
143  protected function setUp() {
144  parent::setUp();
145  $this->m = new MaintenanceFixup( $this );
146  }
147 
148  protected function tearDown() {
149  if ( $this->m ) {
150  $this->m->simulateShutdown();
151  $this->m = null;
152  }
153  parent::tearDown();
154  }
155 
168  private function assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending ) {
169 
170  $this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
171  "Output before shutdown simulation" );
172 
173  $this->m->simulateShutdown();
174  $this->m = null;
175 
176  $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ? "\n" : "" );
177  $this->expectOutputString( $postShutdownOutput );
178  }
179 
180  // Although the following tests do not seem to be too consistent (compare for
181  // example the newlines within the test.*StringString tests, or the
182  // test.*Intermittent.* tests), the objective of these tests is not to describe
183  // consistent behavior, but rather currently existing behavior.
184 
185  function testOutputEmpty() {
186  $this->m->output( "" );
187  $this->assertOutputPrePostShutdown( "", false );
188  }
189 
190  function testOutputString() {
191  $this->m->output( "foo" );
192  $this->assertOutputPrePostShutdown( "foo", false );
193  }
194 
195  function testOutputStringString() {
196  $this->m->output( "foo" );
197  $this->m->output( "bar" );
198  $this->assertOutputPrePostShutdown( "foobar", false );
199  }
200 
201  function testOutputStringNL() {
202  $this->m->output( "foo\n" );
203  $this->assertOutputPrePostShutdown( "foo\n", false );
204  }
205 
206  function testOutputStringNLNL() {
207  $this->m->output( "foo\n\n" );
208  $this->assertOutputPrePostShutdown( "foo\n\n", false );
209  }
210 
211  function testOutputStringNLString() {
212  $this->m->output( "foo\nbar" );
213  $this->assertOutputPrePostShutdown( "foo\nbar", false );
214  }
215 
216  function testOutputStringNLStringNL() {
217  $this->m->output( "foo\nbar\n" );
218  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
219  }
220 
222  $this->m->output( "foo\n" );
223  $this->m->output( "bar\n" );
224  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
225  }
226 
228  $this->m->output( "" );
229  $this->m->output( "foo" );
230  $this->m->output( "" );
231  $this->m->output( "\n" );
232  $this->m->output( "ba" );
233  $this->m->output( "" );
234  $this->m->output( "r\n" );
235  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
236  }
237 
239  $this->m->output( "" );
240  $this->m->output( "foo" );
241  $this->m->output( "" );
242  $this->m->output( "\nb" );
243  $this->m->output( "a" );
244  $this->m->output( "" );
245  $this->m->output( "r\n" );
246  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
247  }
248 
249  function testOutputWNullChannelEmpty() {
250  $this->m->output( "", null );
251  $this->assertOutputPrePostShutdown( "", false );
252  }
253 
254  function testOutputWNullChannelString() {
255  $this->m->output( "foo", null );
256  $this->assertOutputPrePostShutdown( "foo", false );
257  }
258 
260  $this->m->output( "foo", null );
261  $this->m->output( "bar", null );
262  $this->assertOutputPrePostShutdown( "foobar", false );
263  }
264 
265  function testOutputWNullChannelStringNL() {
266  $this->m->output( "foo\n", null );
267  $this->assertOutputPrePostShutdown( "foo\n", false );
268  }
269 
271  $this->m->output( "foo\n\n", null );
272  $this->assertOutputPrePostShutdown( "foo\n\n", false );
273  }
274 
276  $this->m->output( "foo\nbar", null );
277  $this->assertOutputPrePostShutdown( "foo\nbar", false );
278  }
279 
281  $this->m->output( "foo\nbar\n", null );
282  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
283  }
284 
286  $this->m->output( "foo\n", null );
287  $this->m->output( "bar\n", null );
288  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
289  }
290 
292  $this->m->output( "", null );
293  $this->m->output( "foo", null );
294  $this->m->output( "", null );
295  $this->m->output( "\n", null );
296  $this->m->output( "ba", null );
297  $this->m->output( "", null );
298  $this->m->output( "r\n", null );
299  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
300  }
301 
303  $this->m->output( "", null );
304  $this->m->output( "foo", null );
305  $this->m->output( "", null );
306  $this->m->output( "\nb", null );
307  $this->m->output( "a", null );
308  $this->m->output( "", null );
309  $this->m->output( "r\n", null );
310  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
311  }
312 
313  function testOutputWChannelString() {
314  $this->m->output( "foo", "bazChannel" );
315  $this->assertOutputPrePostShutdown( "foo", true );
316  }
317 
318  function testOutputWChannelStringNL() {
319  $this->m->output( "foo\n", "bazChannel" );
320  $this->assertOutputPrePostShutdown( "foo", true );
321  }
322 
323  function testOutputWChannelStringNLNL() {
324  // If this test fails, note that output takes strings with double line
325  // endings (although output's implementation in this situation calls
326  // outputChanneled with a string ending in a nl ... which is not allowed
327  // according to the documentation of outputChanneled)
328  $this->m->output( "foo\n\n", "bazChannel" );
329  $this->assertOutputPrePostShutdown( "foo\n", true );
330  }
331 
333  $this->m->output( "foo\nbar", "bazChannel" );
334  $this->assertOutputPrePostShutdown( "foo\nbar", true );
335  }
336 
338  $this->m->output( "foo\nbar\n", "bazChannel" );
339  $this->assertOutputPrePostShutdown( "foo\nbar", true );
340  }
341 
343  $this->m->output( "foo\n", "bazChannel" );
344  $this->m->output( "bar\n", "bazChannel" );
345  $this->assertOutputPrePostShutdown( "foobar", true );
346  }
347 
349  $this->m->output( "", "bazChannel" );
350  $this->m->output( "foo", "bazChannel" );
351  $this->m->output( "", "bazChannel" );
352  $this->m->output( "\n", "bazChannel" );
353  $this->m->output( "ba", "bazChannel" );
354  $this->m->output( "", "bazChannel" );
355  $this->m->output( "r\n", "bazChannel" );
356  $this->assertOutputPrePostShutdown( "foobar", true );
357  }
358 
360  $this->m->output( "", "bazChannel" );
361  $this->m->output( "foo", "bazChannel" );
362  $this->m->output( "", "bazChannel" );
363  $this->m->output( "\nb", "bazChannel" );
364  $this->m->output( "a", "bazChannel" );
365  $this->m->output( "", "bazChannel" );
366  $this->m->output( "r\n", "bazChannel" );
367  $this->assertOutputPrePostShutdown( "foo\nbar", true );
368  }
369 
371  $this->m->output( "foo", "bazChannel" );
372  $this->m->output( "bar", "bazChannel" );
373  $this->m->output( "qux", "quuxChannel" );
374  $this->m->output( "corge", "bazChannel" );
375  $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
376  }
377 
379  $this->m->output( "foo", "bazChannel" );
380  $this->m->output( "bar\n", "bazChannel" );
381  $this->m->output( "qux\n", "quuxChannel" );
382  $this->m->output( "corge", "bazChannel" );
383  $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
384  }
385 
387  $this->m->output( "foo" );
388  $this->m->output( "bar", "bazChannel" );
389  $this->m->output( "qux" );
390  $this->m->output( "quux", "bazChannel" );
391  $this->assertOutputPrePostShutdown( "foobar\nquxquux", true );
392  }
393 
395  $this->m->output( "foo", "bazChannel" );
396  $this->m->output( "bar" );
397  $this->m->output( "qux", "bazChannel" );
398  $this->m->output( "quux" );
399  $this->assertOutputPrePostShutdown( "foo\nbarqux\nquux", false );
400  }
401 
402  function testOutputWChannelTypeSwitch() {
403  $this->m->output( "foo", 1 );
404  $this->m->output( "bar", 1.0 );
405  $this->assertOutputPrePostShutdown( "foo\nbar", true );
406  }
407 
408  function testOutputIntermittentEmpty() {
409  $this->m->output( "foo" );
410  $this->m->output( "" );
411  $this->m->output( "bar" );
412  $this->assertOutputPrePostShutdown( "foobar", false );
413  }
414 
415  function testOutputIntermittentFalse() {
416  $this->m->output( "foo" );
417  $this->m->output( false );
418  $this->m->output( "bar" );
419  $this->assertOutputPrePostShutdown( "foobar", false );
420  }
421 
423  $this->m->output( "qux", "quuxChannel" );
424  $this->m->output( "foo" );
425  $this->m->output( false );
426  $this->m->output( "bar" );
427  $this->assertOutputPrePostShutdown( "qux\nfoobar", false );
428  }
429 
431  $this->m->output( "foo", null );
432  $this->m->output( "", null );
433  $this->m->output( "bar", null );
434  $this->assertOutputPrePostShutdown( "foobar", false );
435  }
436 
438  $this->m->output( "foo", null );
439  $this->m->output( false, null );
440  $this->m->output( "bar", null );
441  $this->assertOutputPrePostShutdown( "foobar", false );
442  }
443 
445  $this->m->output( "foo", "bazChannel" );
446  $this->m->output( "", "bazChannel" );
447  $this->m->output( "bar", "bazChannel" );
448  $this->assertOutputPrePostShutdown( "foobar", true );
449  }
450 
452  $this->m->output( "foo", "bazChannel" );
453  $this->m->output( false, "bazChannel" );
454  $this->m->output( "bar", "bazChannel" );
455  $this->assertOutputPrePostShutdown( "foobar", true );
456  }
457 
458  // Note that (per documentation) outputChanneled does take strings that end
459  // in \n, hence we do not test such strings.
460 
461  function testOutputChanneledEmpty() {
462  $this->m->outputChanneled( "" );
463  $this->assertOutputPrePostShutdown( "\n", false );
464  }
465 
466  function testOutputChanneledString() {
467  $this->m->outputChanneled( "foo" );
468  $this->assertOutputPrePostShutdown( "foo\n", false );
469  }
470 
472  $this->m->outputChanneled( "foo" );
473  $this->m->outputChanneled( "bar" );
474  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
475  }
476 
478  $this->m->outputChanneled( "foo\nbar" );
479  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
480  }
481 
483  $this->m->outputChanneled( "" );
484  $this->m->outputChanneled( "foo" );
485  $this->m->outputChanneled( "" );
486  $this->m->outputChanneled( "\nb" );
487  $this->m->outputChanneled( "a" );
488  $this->m->outputChanneled( "" );
489  $this->m->outputChanneled( "r" );
490  $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
491  }
492 
494  $this->m->outputChanneled( "", null );
495  $this->assertOutputPrePostShutdown( "\n", false );
496  }
497 
499  $this->m->outputChanneled( "foo", null );
500  $this->assertOutputPrePostShutdown( "foo\n", false );
501  }
502 
504  $this->m->outputChanneled( "foo", null );
505  $this->m->outputChanneled( "bar", null );
506  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
507  }
508 
510  $this->m->outputChanneled( "foo\nbar", null );
511  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
512  }
513 
515  $this->m->outputChanneled( "", null );
516  $this->m->outputChanneled( "foo", null );
517  $this->m->outputChanneled( "", null );
518  $this->m->outputChanneled( "\nb", null );
519  $this->m->outputChanneled( "a", null );
520  $this->m->outputChanneled( "", null );
521  $this->m->outputChanneled( "r", null );
522  $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
523  }
524 
526  $this->m->outputChanneled( "foo", "bazChannel" );
527  $this->assertOutputPrePostShutdown( "foo", true );
528  }
529 
531  $this->m->outputChanneled( "foo\nbar", "bazChannel" );
532  $this->assertOutputPrePostShutdown( "foo\nbar", true );
533  }
534 
536  $this->m->outputChanneled( "foo", "bazChannel" );
537  $this->m->outputChanneled( "bar", "bazChannel" );
538  $this->assertOutputPrePostShutdown( "foobar", true );
539  }
540 
542  $this->m->outputChanneled( "", "bazChannel" );
543  $this->m->outputChanneled( "foo", "bazChannel" );
544  $this->m->outputChanneled( "", "bazChannel" );
545  $this->m->outputChanneled( "\nb", "bazChannel" );
546  $this->m->outputChanneled( "a", "bazChannel" );
547  $this->m->outputChanneled( "", "bazChannel" );
548  $this->m->outputChanneled( "r", "bazChannel" );
549  $this->assertOutputPrePostShutdown( "foo\nbar", true );
550  }
551 
553  $this->m->outputChanneled( "foo", "bazChannel" );
554  $this->m->outputChanneled( "bar", "bazChannel" );
555  $this->m->outputChanneled( "qux", "quuxChannel" );
556  $this->m->outputChanneled( "corge", "bazChannel" );
557  $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
558  }
559 
561  $this->m->outputChanneled( "foo", "bazChannel" );
562  $this->m->outputChanneled( "bar", null );
563  $this->m->outputChanneled( "qux", null );
564  $this->m->outputChanneled( "corge", "bazChannel" );
565  $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
566  }
567 
569  $this->m->outputChanneled( "foo", "bazChannel" );
570  $this->m->outputChanneled( "bar", null );
571  $this->m->outputChanneled( "qux", null );
572  $this->m->outputChanneled( "corge", "quuxChannel" );
573  $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
574  }
575 
577  $this->m->outputChanneled( "foo" );
578  $this->m->outputChanneled( "bar", "bazChannel" );
579  $this->m->outputChanneled( "qux" );
580  $this->m->outputChanneled( "quux", "bazChannel" );
581  $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux", true );
582  }
583 
585  $this->m->outputChanneled( "foo", "bazChannel" );
586  $this->m->outputChanneled( "bar" );
587  $this->m->outputChanneled( "qux", "bazChannel" );
588  $this->m->outputChanneled( "quux" );
589  $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux\n", false );
590  }
591 
593  $this->m->outputChanneled( "foo", 1 );
594  $this->m->outputChanneled( "bar", 1.0 );
595  $this->assertOutputPrePostShutdown( "foo\nbar", true );
596  }
597 
599  $this->m->outputChanneled( "foo" );
600  $this->m->outputChanneled( "" );
601  $this->m->outputChanneled( "bar" );
602  $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
603  }
604 
606  $this->m->outputChanneled( "foo" );
607  $this->m->outputChanneled( false );
608  $this->m->outputChanneled( "bar" );
609  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
610  }
611 
613  $this->m->outputChanneled( "foo", null );
614  $this->m->outputChanneled( "", null );
615  $this->m->outputChanneled( "bar", null );
616  $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
617  }
618 
620  $this->m->outputChanneled( "foo", null );
621  $this->m->outputChanneled( false, null );
622  $this->m->outputChanneled( "bar", null );
623  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
624  }
625 
627  $this->m->outputChanneled( "foo", "bazChannel" );
628  $this->m->outputChanneled( "", "bazChannel" );
629  $this->m->outputChanneled( "bar", "bazChannel" );
630  $this->assertOutputPrePostShutdown( "foobar", true );
631  }
632 
634  $this->m->outputChanneled( "foo", "bazChannel" );
635  $this->m->outputChanneled( false, "bazChannel" );
636  $this->m->outputChanneled( "bar", "bazChannel" );
637  $this->assertOutputPrePostShutdown( "foo\nbar", true );
638  }
639 
640  function testCleanupChanneledClean() {
641  $this->m->cleanupChanneled();
642  $this->assertOutputPrePostShutdown( "", false );
643  }
644 
646  $this->m->output( "foo" );
647  $this->m->cleanupChanneled();
648  $this->assertOutputPrePostShutdown( "foo", false );
649  }
650 
652  $this->m->output( "foo", null );
653  $this->m->cleanupChanneled();
654  $this->assertOutputPrePostShutdown( "foo", false );
655  }
656 
658  $this->m->output( "foo", "bazChannel" );
659  $this->m->cleanupChanneled();
660  $this->assertOutputPrePostShutdown( "foo\n", false );
661  }
662 
664  $this->m->output( "foo\n" );
665  $this->m->cleanupChanneled();
666  $this->assertOutputPrePostShutdown( "foo\n", false );
667  }
668 
670  $this->m->output( "foo\n", null );
671  $this->m->cleanupChanneled();
672  $this->assertOutputPrePostShutdown( "foo\n", false );
673  }
674 
676  $this->m->output( "foo\n", "bazChannel" );
677  $this->m->cleanupChanneled();
678  $this->assertOutputPrePostShutdown( "foo\n", false );
679  }
680 
682  $this->m->outputChanneled( "foo" );
683  $this->m->cleanupChanneled();
684  $this->assertOutputPrePostShutdown( "foo\n", false );
685  }
686 
688  $this->m->outputChanneled( "foo", null );
689  $this->m->cleanupChanneled();
690  $this->assertOutputPrePostShutdown( "foo\n", false );
691  }
692 
694  $this->m->outputChanneled( "foo", "bazChannel" );
695  $this->m->cleanupChanneled();
696  $this->assertOutputPrePostShutdown( "foo\n", false );
697  }
698 
700  $m2 = new MaintenanceFixup( $this );
701 
702  $this->m->output( "foo" );
703  $m2->output( "bar" );
704 
705  $this->assertEquals( "foobar", $this->getActualOutput(),
706  "Output before shutdown simulation (m2)" );
707  $m2->simulateShutdown();
708  $this->assertOutputPrePostShutdown( "foobar", false );
709  }
710 
712  $m2 = new MaintenanceFixup( $this );
713 
714  $this->m->output( "foo", null );
715  $m2->output( "bar", null );
716 
717  $this->assertEquals( "foobar", $this->getActualOutput(),
718  "Output before shutdown simulation (m2)" );
719  $m2->simulateShutdown();
720  $this->assertOutputPrePostShutdown( "foobar", false );
721  }
722 
724  $m2 = new MaintenanceFixup( $this );
725 
726  $this->m->output( "foo", "bazChannel" );
727  $m2->output( "bar", "bazChannel" );
728 
729  $this->assertEquals( "foobar", $this->getActualOutput(),
730  "Output before shutdown simulation (m2)" );
731  $m2->simulateShutdown();
732  $this->assertOutputPrePostShutdown( "foobar\n", true );
733  }
734 
736  $m2 = new MaintenanceFixup( $this );
737 
738  $this->m->output( "foo\n", null );
739  $m2->output( "bar\n", null );
740 
741  $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
742  "Output before shutdown simulation (m2)" );
743  $m2->simulateShutdown();
744  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
745  }
746 
748  $m2 = new MaintenanceFixup( $this );
749 
750  $this->m->output( "foo\n", "bazChannel" );
751  $m2->output( "bar\n", "bazChannel" );
752 
753  $this->assertEquals( "foobar", $this->getActualOutput(),
754  "Output before shutdown simulation (m2)" );
755  $m2->simulateShutdown();
756  $this->assertOutputPrePostShutdown( "foobar\n", true );
757  }
758 
760  $m2 = new MaintenanceFixup( $this );
761 
762  $this->m->outputChanneled( "foo" );
763  $m2->outputChanneled( "bar" );
764 
765  $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
766  "Output before shutdown simulation (m2)" );
767  $m2->simulateShutdown();
768  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
769  }
770 
772  $m2 = new MaintenanceFixup( $this );
773 
774  $this->m->outputChanneled( "foo", null );
775  $m2->outputChanneled( "bar", null );
776 
777  $this->assertEquals( "foo\nbar\n", $this->getActualOutput(),
778  "Output before shutdown simulation (m2)" );
779  $m2->simulateShutdown();
780  $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
781  }
782 
784  $m2 = new MaintenanceFixup( $this );
785 
786  $this->m->outputChanneled( "foo", "bazChannel" );
787  $m2->outputChanneled( "bar", "bazChannel" );
788 
789  $this->assertEquals( "foobar", $this->getActualOutput(),
790  "Output before shutdown simulation (m2)" );
791  $m2->simulateShutdown();
792  $this->assertOutputPrePostShutdown( "foobar\n", true );
793  }
794 
796  $m2 = new MaintenanceFixup( $this );
797 
798  $this->m->outputChanneled( "foo", "bazChannel" );
799  $m2->outputChanneled( "bar", "bazChannel" );
800 
801  $this->assertEquals( "foobar", $this->getActualOutput(),
802  "Output before first cleanup" );
803  $this->m->cleanupChanneled();
804  $this->assertEquals( "foobar\n", $this->getActualOutput(),
805  "Output after first cleanup" );
806  $m2->cleanupChanneled();
807  $this->assertEquals( "foobar\n\n", $this->getActualOutput(),
808  "Output after second cleanup" );
809 
810  $m2->simulateShutdown();
811  $this->assertOutputPrePostShutdown( "foobar\n\n", false );
812  }
813 }
MaintenanceFixup
makes parts of the API of Maintenance that is hidden by protected visibily visible for testing,...
Definition: MaintenanceTest.php:29
MaintenanceTest\testOutputWChannelStringNL
testOutputWChannelStringNL()
Definition: MaintenanceTest.php:315
MaintenanceTest\testOutputWNullChannelString
testOutputWNullChannelString()
Definition: MaintenanceTest.php:251
MaintenanceFixup\output
output( $out, $channel=null)
Throw some output to the user.
Definition: MaintenanceTest.php:114
MaintenanceTest\testMultipleMaintenanceObjectsInteractionOutputChanneled
testMultipleMaintenanceObjectsInteractionOutputChanneled()
Definition: MaintenanceTest.php:756
MaintenanceTest\setUp
setUp()
Definition: MaintenanceTest.php:140
MaintenanceTest\testOutputChanneledWAndWOChannelStringStartWO
testOutputChanneledWAndWOChannelStringStartWO()
Definition: MaintenanceTest.php:573
MaintenanceTest\testOutputWNullChannelStringNLString
testOutputWNullChannelStringNLString()
Definition: MaintenanceTest.php:272
MaintenanceTest\testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel
testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel()
Definition: MaintenanceTest.php:792
MaintenanceTest\testOutputWNullChannelEmpty
testOutputWNullChannelEmpty()
Definition: MaintenanceTest.php:246
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
MaintenanceTest\testCleanupChanneledAfterNLOutput
testCleanupChanneledAfterNLOutput()
Definition: MaintenanceTest.php:660
MaintenanceTest\testOutputWChannelStringNLNL
testOutputWChannelStringNLNL()
Definition: MaintenanceTest.php:320
MaintenanceTest\testOutputWMultipleChannelsChannelChange
testOutputWMultipleChannelsChannelChange()
Definition: MaintenanceTest.php:367
MaintenanceTest\testOutputWChannelStringNLStringNLLinewise
testOutputWChannelStringNLStringNLLinewise()
Definition: MaintenanceTest.php:339
MaintenanceTest\testCleanupChanneledAfterOutputChanneledWOChannel
testCleanupChanneledAfterOutputChanneledWOChannel()
Definition: MaintenanceTest.php:678
MaintenanceFixup\simulateShutdown
simulateShutdown()
Simulates what Maintenance wants to happen at script's end.
Definition: MaintenanceTest.php:53
MaintenanceTest\assertOutputPrePostShutdown
assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending)
asserts the output before and after simulating shutdown
Definition: MaintenanceTest.php:165
MaintenanceTest\testOutputStringNLNL
testOutputStringNLNL()
Definition: MaintenanceTest.php:203
MaintenanceTest\testOutputWNullChannelStringNLStringNL
testOutputWNullChannelStringNLStringNL()
Definition: MaintenanceTest.php:277
MaintenanceTest\testOutputStringNLStringNLArbitraryAgain
testOutputStringNLStringNLArbitraryAgain()
Definition: MaintenanceTest.php:235
MaintenanceTest\testOutputChanneledStringNLString
testOutputChanneledStringNLString()
Definition: MaintenanceTest.php:474
MaintenanceFixup\outputChanneled
outputChanneled( $msg, $channel=null)
Message outputter with channeled message support.
Definition: MaintenanceTest.php:67
MaintenanceTest\testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel
testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel()
Definition: MaintenanceTest.php:780
MaintenanceTest\testOutputWNullChannelStringNLStringNLArbitraryAgain
testOutputWNullChannelStringNLStringNLArbitraryAgain()
Definition: MaintenanceTest.php:299
MaintenanceFixup\$shutdownSimulated
bool $shutdownSimulated
shutdownSimulated === true if simulateShutdown has done it's work
Definition: MaintenanceTest.php:48
MaintenanceTest\testOutputString
testOutputString()
Definition: MaintenanceTest.php:187
MaintenanceTest\testOutputWNullChannelStringString
testOutputWNullChannelStringString()
Definition: MaintenanceTest.php:256
MaintenanceTest\testOutputStringNLStringNLLinewise
testOutputStringNLStringNLLinewise()
Definition: MaintenanceTest.php:218
MaintenanceTest\testCleanupChanneledAfterOutputWNullChannel
testCleanupChanneledAfterOutputWNullChannel()
Definition: MaintenanceTest.php:648
MaintenanceFixup\__construct
__construct(MediaWikiTestCase $testCase)
Definition: MaintenanceTest.php:107
MaintenanceTest\testOutputWChannelIntermittentEmpty
testOutputWChannelIntermittentEmpty()
Definition: MaintenanceTest.php:441
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
MaintenanceTest\testOutputChanneledWNullChannelStringString
testOutputChanneledWNullChannelStringString()
Definition: MaintenanceTest.php:500
MaintenanceTest\testOutputChanneledStringNLStringNLArbitraryAgain
testOutputChanneledStringNLStringNLArbitraryAgain()
Definition: MaintenanceTest.php:479
MaintenanceTest\testMultipleMaintenanceObjectsInteractionOutputWNullChannel
testMultipleMaintenanceObjectsInteractionOutputWNullChannel()
Definition: MaintenanceTest.php:708
MaintenanceTest\testOutputWChannelIntermittentFalse
testOutputWChannelIntermittentFalse()
Definition: MaintenanceTest.php:448
MaintenanceTest\testOutputWChannelTypeSwitch
testOutputWChannelTypeSwitch()
Definition: MaintenanceTest.php:399
MaintenanceTest\testCleanupChanneledAfterNLOutputWChannel
testCleanupChanneledAfterNLOutputWChannel()
Definition: MaintenanceTest.php:672
MaintenanceTest\testMultipleMaintenanceObjectsInteractionOutputWChannel
testMultipleMaintenanceObjectsInteractionOutputWChannel()
Definition: MaintenanceTest.php:720
MaintenanceTest\testOutputStringNL
testOutputStringNL()
Definition: MaintenanceTest.php:198
MaintenanceTest\testOutputChanneledWChannelString
testOutputChanneledWChannelString()
Definition: MaintenanceTest.php:522
MaintenanceTest\testOutputIntermittentFalse
testOutputIntermittentFalse()
Definition: MaintenanceTest.php:412
MaintenanceTest\testOutputStringNLStringNLArbitrary
testOutputStringNLStringNLArbitrary()
Definition: MaintenanceTest.php:224
MaintenanceTest\testOutputChanneledWChannelStringString
testOutputChanneledWChannelStringString()
Definition: MaintenanceTest.php:532
MaintenanceTest\testOutputWAndWOChannelStringStartWO
testOutputWAndWOChannelStringStartWO()
Definition: MaintenanceTest.php:383
MaintenanceTest\testOutputChanneledWAndWOChannelStringStartW
testOutputChanneledWAndWOChannelStringStartW()
Definition: MaintenanceTest.php:581
MaintenanceTest\testOutputWChannelStringNLStringNLArbitraryAgain
testOutputWChannelStringNLStringNLArbitraryAgain()
Definition: MaintenanceTest.php:356
Maintenance::__construct
public function __construct()
Definition: maintenance.txt:41
$out
$out
Definition: UtfNormalGenerate.php:167
MaintenanceTest\testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL
testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL()
Definition: MaintenanceTest.php:732
MaintenanceTest\tearDown
tearDown()
Definition: MaintenanceTest.php:145
MaintenanceTest\testCleanupChanneledAfterNLOutputWNullChannel
testCleanupChanneledAfterNLOutputWNullChannel()
Definition: MaintenanceTest.php:666
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
MaintenanceTest\testOutputChanneledWMultipleChannelsChannelChange
testOutputChanneledWMultipleChannelsChannelChange()
Definition: MaintenanceTest.php:549
MaintenanceTest\testOutputWNullChannelStringNL
testOutputWNullChannelStringNL()
Definition: MaintenanceTest.php:262
MaintenanceTest\testOutputChanneledWNullChannelEmpty
testOutputChanneledWNullChannelEmpty()
Definition: MaintenanceTest.php:490
MaintenanceTest\testOutputStringString
testOutputStringString()
Definition: MaintenanceTest.php:192
MaintenanceTest\testOutputChanneledWNullChannelIntermittentEmpty
testOutputChanneledWNullChannelIntermittentEmpty()
Definition: MaintenanceTest.php:609
MaintenanceTest\testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull
testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull()
Definition: MaintenanceTest.php:557
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
MaintenanceTest\testOutputChanneledWOChannelIntermittentEmpty
testOutputChanneledWOChannelIntermittentEmpty()
Definition: MaintenanceTest.php:595
MaintenanceTest\testOutputChanneledWChannelStringNLString
testOutputChanneledWChannelStringNLString()
Definition: MaintenanceTest.php:527
MaintenanceTest\testOutputChanneledWOChannelIntermittentFalse
testOutputChanneledWOChannelIntermittentFalse()
Definition: MaintenanceTest.php:602
MaintenanceTest\testOutputChanneledWNullChannelStringNLString
testOutputChanneledWNullChannelStringNLString()
Definition: MaintenanceTest.php:506
MaintenanceTest
@covers Maintenance
Definition: MaintenanceTest.php:132
MaintenanceTest\testOutputChanneledWNullChannelIntermittentFalse
testOutputChanneledWNullChannelIntermittentFalse()
Definition: MaintenanceTest.php:616
MaintenanceTest\testMultipleMaintenanceObjectsInteractionOutputWChannelNL
testMultipleMaintenanceObjectsInteractionOutputWChannelNL()
Definition: MaintenanceTest.php:744
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
MaintenanceTest\testOutputStringNLString
testOutputStringNLString()
Definition: MaintenanceTest.php:208
MaintenanceTest\testOutputWMultipleChannelsChannelChangeNL
testOutputWMultipleChannelsChannelChangeNL()
Definition: MaintenanceTest.php:375
MaintenanceTest\testOutputChanneledWChannelIntermittentEmpty
testOutputChanneledWChannelIntermittentEmpty()
Definition: MaintenanceTest.php:623
MaintenanceTest\testOutputWChannelStringNLStringNL
testOutputWChannelStringNLStringNL()
Definition: MaintenanceTest.php:334
MaintenanceTest\testOutputWNullChannelIntermittentFalse
testOutputWNullChannelIntermittentFalse()
Definition: MaintenanceTest.php:434
MaintenanceFixup\__destruct
__destruct()
Safety net around register_shutdown_function of Maintenance.php.
Definition: MaintenanceTest.php:88
MaintenanceTest\testOutputWNullChannelStringNLStringNLLinewise
testOutputWNullChannelStringNLStringNLLinewise()
Definition: MaintenanceTest.php:282
MaintenanceTest\testOutputWNullChannelStringNLNL
testOutputWNullChannelStringNLNL()
Definition: MaintenanceTest.php:267
MaintenanceTest\testOutputChanneledString
testOutputChanneledString()
Definition: MaintenanceTest.php:463
MaintenanceTest\testOutputWAndWOChannelStringStartW
testOutputWAndWOChannelStringStartW()
Definition: MaintenanceTest.php:391
MaintenanceTest\testOutputStringNLStringNL
testOutputStringNLStringNL()
Definition: MaintenanceTest.php:213
MaintenanceTest\testOutputWNullChannelStringNLStringNLArbitrary
testOutputWNullChannelStringNLStringNLArbitrary()
Definition: MaintenanceTest.php:288
MaintenanceTest\testMultipleMaintenanceObjectsInteractionOutput
testMultipleMaintenanceObjectsInteractionOutput()
Definition: MaintenanceTest.php:696
MaintenanceTest\testOutputChanneledEmpty
testOutputChanneledEmpty()
Definition: MaintenanceTest.php:458
MaintenanceTest\testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel
testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel()
Definition: MaintenanceTest.php:768
MaintenanceTest\testOutputIntermittentFalseAfterOtherChannel
testOutputIntermittentFalseAfterOtherChannel()
Definition: MaintenanceTest.php:419
MaintenanceTest\testOutputWNullChannelIntermittentEmpty
testOutputWNullChannelIntermittentEmpty()
Definition: MaintenanceTest.php:427
MaintenanceTest\testCleanupChanneledAfterOutputChanneledWChannel
testCleanupChanneledAfterOutputChanneledWChannel()
Definition: MaintenanceTest.php:690
MaintenanceTest\testOutputChanneledWNullChannelString
testOutputChanneledWNullChannelString()
Definition: MaintenanceTest.php:495
MaintenanceTest\testCleanupChanneledAfterOutputChanneledWNullChannel
testCleanupChanneledAfterOutputChanneledWNullChannel()
Definition: MaintenanceTest.php:684
MaintenanceTest\testCleanupChanneledAfterOutput
testCleanupChanneledAfterOutput()
Definition: MaintenanceTest.php:642
MaintenanceTest\testOutputWChannelString
testOutputWChannelString()
Definition: MaintenanceTest.php:310
MaintenanceTest\testOutputEmpty
testOutputEmpty()
Definition: MaintenanceTest.php:182
MaintenanceTest\$m
MaintenanceFixup $m
The main Maintenance instance that is used for testing.
Definition: MaintenanceTest.php:138
MaintenanceTest\testOutputIntermittentEmpty
testOutputIntermittentEmpty()
Definition: MaintenanceTest.php:405
MaintenanceTest\testCleanupChanneledAfterOutputWChannel
testCleanupChanneledAfterOutputWChannel()
Definition: MaintenanceTest.php:654
MaintenanceTest\testOutputChanneledStringString
testOutputChanneledStringString()
Definition: MaintenanceTest.php:468
MaintenanceTest\testOutputWChannelStringNLString
testOutputWChannelStringNLString()
Definition: MaintenanceTest.php:329
MaintenanceTest\testOutputWChannelStringNLStringNLArbitrary
testOutputWChannelStringNLStringNLArbitrary()
Definition: MaintenanceTest.php:345
MaintenanceFixup\execute
execute()
Do the actual work.
Definition: MaintenanceTest.php:124
MaintenanceTest\testOutputChanneledWChannelIntermittentFalse
testOutputChanneledWChannelIntermittentFalse()
Definition: MaintenanceTest.php:630
MaintenanceFixup\$testCase
MediaWikiTestCase $testCase
The test case that generated this instance.
Definition: MaintenanceTest.php:42
MaintenanceTest\testCleanupChanneledClean
testCleanupChanneledClean()
Definition: MaintenanceTest.php:637
MaintenanceTest\testOutputChanneledWChannelTypeSwitch
testOutputChanneledWChannelTypeSwitch()
Definition: MaintenanceTest.php:589
MaintenanceTest\testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain
testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain()
Definition: MaintenanceTest.php:511
MaintenanceTest\testOutputChanneledWChannelStringNLStringNLArbitraryAgain
testOutputChanneledWChannelStringNLStringNLArbitraryAgain()
Definition: MaintenanceTest.php:538
MaintenanceTest\testOutputChanneledWMultipleChannelsChannelAfterNullChange
testOutputChanneledWMultipleChannelsChannelAfterNullChange()
Definition: MaintenanceTest.php:565