Replace some of MaintenanceTest with dataProviders
authorAdam Roses Wight <awight@wikimedia.org>
Wed, 17 Jan 2018 13:33:10 +0000 (08:33 -0500)
committerLegoktm <legoktm@member.fsf.org>
Mon, 22 Jan 2018 06:43:05 +0000 (06:43 +0000)
Bug: T184775
Change-Id: Icbaf3cbcf3c51e5b4cd53d55a5230534e74a0a38

tests/phpunit/maintenance/MaintenanceTest.php

index f29cacd..141561f 100644 (file)
@@ -37,459 +37,272 @@ class MaintenanceTest extends MaintenanceBaseTestCase {
        // test.*Intermittent.* tests), the objective of these tests is not to describe
        // consistent behavior, but rather currently existing behavior.
 
-       function testOutputEmpty() {
-               $this->maintenance->output( "" );
-               $this->assertOutputPrePostShutdown( "", false );
-       }
-
-       function testOutputString() {
-               $this->maintenance->output( "foo" );
-               $this->assertOutputPrePostShutdown( "foo", false );
-       }
-
-       function testOutputStringString() {
-               $this->maintenance->output( "foo" );
-               $this->maintenance->output( "bar" );
-               $this->assertOutputPrePostShutdown( "foobar", false );
-       }
-
-       function testOutputStringNL() {
-               $this->maintenance->output( "foo\n" );
-               $this->assertOutputPrePostShutdown( "foo\n", false );
-       }
-
-       function testOutputStringNLNL() {
-               $this->maintenance->output( "foo\n\n" );
-               $this->assertOutputPrePostShutdown( "foo\n\n", false );
-       }
-
-       function testOutputStringNLString() {
-               $this->maintenance->output( "foo\nbar" );
-               $this->assertOutputPrePostShutdown( "foo\nbar", false );
-       }
-
-       function testOutputStringNLStringNL() {
-               $this->maintenance->output( "foo\nbar\n" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputStringNLStringNLLinewise() {
-               $this->maintenance->output( "foo\n" );
-               $this->maintenance->output( "bar\n" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputStringNLStringNLArbitrary() {
-               $this->maintenance->output( "" );
-               $this->maintenance->output( "foo" );
-               $this->maintenance->output( "" );
-               $this->maintenance->output( "\n" );
-               $this->maintenance->output( "ba" );
-               $this->maintenance->output( "" );
-               $this->maintenance->output( "r\n" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputStringNLStringNLArbitraryAgain() {
-               $this->maintenance->output( "" );
-               $this->maintenance->output( "foo" );
-               $this->maintenance->output( "" );
-               $this->maintenance->output( "\nb" );
-               $this->maintenance->output( "a" );
-               $this->maintenance->output( "" );
-               $this->maintenance->output( "r\n" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputWNullChannelEmpty() {
-               $this->maintenance->output( "", null );
-               $this->assertOutputPrePostShutdown( "", false );
-       }
-
-       function testOutputWNullChannelString() {
-               $this->maintenance->output( "foo", null );
-               $this->assertOutputPrePostShutdown( "foo", false );
-       }
-
-       function testOutputWNullChannelStringString() {
-               $this->maintenance->output( "foo", null );
-               $this->maintenance->output( "bar", null );
-               $this->assertOutputPrePostShutdown( "foobar", false );
-       }
-
-       function testOutputWNullChannelStringNL() {
-               $this->maintenance->output( "foo\n", null );
-               $this->assertOutputPrePostShutdown( "foo\n", false );
-       }
-
-       function testOutputWNullChannelStringNLNL() {
-               $this->maintenance->output( "foo\n\n", null );
-               $this->assertOutputPrePostShutdown( "foo\n\n", false );
-       }
-
-       function testOutputWNullChannelStringNLString() {
-               $this->maintenance->output( "foo\nbar", null );
-               $this->assertOutputPrePostShutdown( "foo\nbar", false );
-       }
-
-       function testOutputWNullChannelStringNLStringNL() {
-               $this->maintenance->output( "foo\nbar\n", null );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputWNullChannelStringNLStringNLLinewise() {
-               $this->maintenance->output( "foo\n", null );
-               $this->maintenance->output( "bar\n", null );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputWNullChannelStringNLStringNLArbitrary() {
-               $this->maintenance->output( "", null );
-               $this->maintenance->output( "foo", null );
-               $this->maintenance->output( "", null );
-               $this->maintenance->output( "\n", null );
-               $this->maintenance->output( "ba", null );
-               $this->maintenance->output( "", null );
-               $this->maintenance->output( "r\n", null );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputWNullChannelStringNLStringNLArbitraryAgain() {
-               $this->maintenance->output( "", null );
-               $this->maintenance->output( "foo", null );
-               $this->maintenance->output( "", null );
-               $this->maintenance->output( "\nb", null );
-               $this->maintenance->output( "a", null );
-               $this->maintenance->output( "", null );
-               $this->maintenance->output( "r\n", null );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputWChannelString() {
-               $this->maintenance->output( "foo", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo", true );
-       }
-
-       function testOutputWChannelStringNL() {
-               $this->maintenance->output( "foo\n", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo", true );
-       }
-
-       function testOutputWChannelStringNLNL() {
-               // If this test fails, note that output takes strings with double line
-               // endings (although output's implementation in this situation calls
-               // outputChanneled with a string ending in a nl ... which is not allowed
-               // according to the documentation of outputChanneled)
-               $this->maintenance->output( "foo\n\n", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo\n", true );
-       }
-
-       function testOutputWChannelStringNLString() {
-               $this->maintenance->output( "foo\nbar", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo\nbar", true );
-       }
-
-       function testOutputWChannelStringNLStringNL() {
-               $this->maintenance->output( "foo\nbar\n", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo\nbar", true );
-       }
-
-       function testOutputWChannelStringNLStringNLLinewise() {
-               $this->maintenance->output( "foo\n", "bazChannel" );
-               $this->maintenance->output( "bar\n", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foobar", true );
-       }
-
-       function testOutputWChannelStringNLStringNLArbitrary() {
-               $this->maintenance->output( "", "bazChannel" );
-               $this->maintenance->output( "foo", "bazChannel" );
-               $this->maintenance->output( "", "bazChannel" );
-               $this->maintenance->output( "\n", "bazChannel" );
-               $this->maintenance->output( "ba", "bazChannel" );
-               $this->maintenance->output( "", "bazChannel" );
-               $this->maintenance->output( "r\n", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foobar", true );
-       }
-
-       function testOutputWChannelStringNLStringNLArbitraryAgain() {
-               $this->maintenance->output( "", "bazChannel" );
-               $this->maintenance->output( "foo", "bazChannel" );
-               $this->maintenance->output( "", "bazChannel" );
-               $this->maintenance->output( "\nb", "bazChannel" );
-               $this->maintenance->output( "a", "bazChannel" );
-               $this->maintenance->output( "", "bazChannel" );
-               $this->maintenance->output( "r\n", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo\nbar", true );
-       }
-
-       function testOutputWMultipleChannelsChannelChange() {
-               $this->maintenance->output( "foo", "bazChannel" );
-               $this->maintenance->output( "bar", "bazChannel" );
-               $this->maintenance->output( "qux", "quuxChannel" );
-               $this->maintenance->output( "corge", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
-       }
-
-       function testOutputWMultipleChannelsChannelChangeNL() {
-               $this->maintenance->output( "foo", "bazChannel" );
-               $this->maintenance->output( "bar\n", "bazChannel" );
-               $this->maintenance->output( "qux\n", "quuxChannel" );
-               $this->maintenance->output( "corge", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
-       }
-
-       function testOutputWAndWOChannelStringStartWO() {
-               $this->maintenance->output( "foo" );
-               $this->maintenance->output( "bar", "bazChannel" );
-               $this->maintenance->output( "qux" );
-               $this->maintenance->output( "quux", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foobar\nquxquux", true );
-       }
-
-       function testOutputWAndWOChannelStringStartW() {
-               $this->maintenance->output( "foo", "bazChannel" );
-               $this->maintenance->output( "bar" );
-               $this->maintenance->output( "qux", "bazChannel" );
-               $this->maintenance->output( "quux" );
-               $this->assertOutputPrePostShutdown( "foo\nbarqux\nquux", false );
-       }
-
-       function testOutputWChannelTypeSwitch() {
-               $this->maintenance->output( "foo", 1 );
-               $this->maintenance->output( "bar", 1.0 );
-               $this->assertOutputPrePostShutdown( "foo\nbar", true );
-       }
-
-       function testOutputIntermittentEmpty() {
-               $this->maintenance->output( "foo" );
-               $this->maintenance->output( "" );
-               $this->maintenance->output( "bar" );
-               $this->assertOutputPrePostShutdown( "foobar", false );
-       }
-
-       function testOutputIntermittentFalse() {
-               $this->maintenance->output( "foo" );
-               $this->maintenance->output( false );
-               $this->maintenance->output( "bar" );
-               $this->assertOutputPrePostShutdown( "foobar", false );
-       }
-
-       function testOutputIntermittentFalseAfterOtherChannel() {
-               $this->maintenance->output( "qux", "quuxChannel" );
-               $this->maintenance->output( "foo" );
-               $this->maintenance->output( false );
-               $this->maintenance->output( "bar" );
-               $this->assertOutputPrePostShutdown( "qux\nfoobar", false );
-       }
-
-       function testOutputWNullChannelIntermittentEmpty() {
-               $this->maintenance->output( "foo", null );
-               $this->maintenance->output( "", null );
-               $this->maintenance->output( "bar", null );
-               $this->assertOutputPrePostShutdown( "foobar", false );
-       }
-
-       function testOutputWNullChannelIntermittentFalse() {
-               $this->maintenance->output( "foo", null );
-               $this->maintenance->output( false, null );
-               $this->maintenance->output( "bar", null );
-               $this->assertOutputPrePostShutdown( "foobar", false );
-       }
-
-       function testOutputWChannelIntermittentEmpty() {
-               $this->maintenance->output( "foo", "bazChannel" );
-               $this->maintenance->output( "", "bazChannel" );
-               $this->maintenance->output( "bar", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foobar", true );
-       }
-
-       function testOutputWChannelIntermittentFalse() {
-               $this->maintenance->output( "foo", "bazChannel" );
-               $this->maintenance->output( false, "bazChannel" );
-               $this->maintenance->output( "bar", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foobar", true );
-       }
-
-       // Note that (per documentation) outputChanneled does take strings that end
-       // in \n, hence we do not test such strings.
-
-       function testOutputChanneledEmpty() {
-               $this->maintenance->outputChanneled( "" );
-               $this->assertOutputPrePostShutdown( "\n", false );
-       }
-
-       function testOutputChanneledString() {
-               $this->maintenance->outputChanneled( "foo" );
-               $this->assertOutputPrePostShutdown( "foo\n", false );
-       }
-
-       function testOutputChanneledStringString() {
-               $this->maintenance->outputChanneled( "foo" );
-               $this->maintenance->outputChanneled( "bar" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputChanneledStringNLString() {
-               $this->maintenance->outputChanneled( "foo\nbar" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputChanneledStringNLStringNLArbitraryAgain() {
-               $this->maintenance->outputChanneled( "" );
-               $this->maintenance->outputChanneled( "foo" );
-               $this->maintenance->outputChanneled( "" );
-               $this->maintenance->outputChanneled( "\nb" );
-               $this->maintenance->outputChanneled( "a" );
-               $this->maintenance->outputChanneled( "" );
-               $this->maintenance->outputChanneled( "r" );
-               $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
-       }
-
-       function testOutputChanneledWNullChannelEmpty() {
-               $this->maintenance->outputChanneled( "", null );
-               $this->assertOutputPrePostShutdown( "\n", false );
-       }
-
-       function testOutputChanneledWNullChannelString() {
-               $this->maintenance->outputChanneled( "foo", null );
-               $this->assertOutputPrePostShutdown( "foo\n", false );
-       }
-
-       function testOutputChanneledWNullChannelStringString() {
-               $this->maintenance->outputChanneled( "foo", null );
-               $this->maintenance->outputChanneled( "bar", null );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputChanneledWNullChannelStringNLString() {
-               $this->maintenance->outputChanneled( "foo\nbar", null );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputChanneledWNullChannelStringNLStringNLArbitraryAgain() {
-               $this->maintenance->outputChanneled( "", null );
-               $this->maintenance->outputChanneled( "foo", null );
-               $this->maintenance->outputChanneled( "", null );
-               $this->maintenance->outputChanneled( "\nb", null );
-               $this->maintenance->outputChanneled( "a", null );
-               $this->maintenance->outputChanneled( "", null );
-               $this->maintenance->outputChanneled( "r", null );
-               $this->assertOutputPrePostShutdown( "\nfoo\n\n\nb\na\n\nr\n", false );
-       }
-
-       function testOutputChanneledWChannelString() {
-               $this->maintenance->outputChanneled( "foo", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo", true );
-       }
-
-       function testOutputChanneledWChannelStringNLString() {
-               $this->maintenance->outputChanneled( "foo\nbar", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo\nbar", true );
-       }
-
-       function testOutputChanneledWChannelStringString() {
-               $this->maintenance->outputChanneled( "foo", "bazChannel" );
-               $this->maintenance->outputChanneled( "bar", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foobar", true );
-       }
-
-       function testOutputChanneledWChannelStringNLStringNLArbitraryAgain() {
-               $this->maintenance->outputChanneled( "", "bazChannel" );
-               $this->maintenance->outputChanneled( "foo", "bazChannel" );
-               $this->maintenance->outputChanneled( "", "bazChannel" );
-               $this->maintenance->outputChanneled( "\nb", "bazChannel" );
-               $this->maintenance->outputChanneled( "a", "bazChannel" );
-               $this->maintenance->outputChanneled( "", "bazChannel" );
-               $this->maintenance->outputChanneled( "r", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo\nbar", true );
-       }
-
-       function testOutputChanneledWMultipleChannelsChannelChange() {
-               $this->maintenance->outputChanneled( "foo", "bazChannel" );
-               $this->maintenance->outputChanneled( "bar", "bazChannel" );
-               $this->maintenance->outputChanneled( "qux", "quuxChannel" );
-               $this->maintenance->outputChanneled( "corge", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foobar\nqux\ncorge", true );
-       }
-
-       function testOutputChanneledWMultipleChannelsChannelChangeEnclosedNull() {
-               $this->maintenance->outputChanneled( "foo", "bazChannel" );
-               $this->maintenance->outputChanneled( "bar", null );
-               $this->maintenance->outputChanneled( "qux", null );
-               $this->maintenance->outputChanneled( "corge", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
-       }
-
-       function testOutputChanneledWMultipleChannelsChannelAfterNullChange() {
-               $this->maintenance->outputChanneled( "foo", "bazChannel" );
-               $this->maintenance->outputChanneled( "bar", null );
-               $this->maintenance->outputChanneled( "qux", null );
-               $this->maintenance->outputChanneled( "corge", "quuxChannel" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\nqux\ncorge", true );
-       }
-
-       function testOutputChanneledWAndWOChannelStringStartWO() {
-               $this->maintenance->outputChanneled( "foo" );
-               $this->maintenance->outputChanneled( "bar", "bazChannel" );
-               $this->maintenance->outputChanneled( "qux" );
-               $this->maintenance->outputChanneled( "quux", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux", true );
-       }
-
-       function testOutputChanneledWAndWOChannelStringStartW() {
-               $this->maintenance->outputChanneled( "foo", "bazChannel" );
-               $this->maintenance->outputChanneled( "bar" );
-               $this->maintenance->outputChanneled( "qux", "bazChannel" );
-               $this->maintenance->outputChanneled( "quux" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\nqux\nquux\n", false );
-       }
-
-       function testOutputChanneledWChannelTypeSwitch() {
-               $this->maintenance->outputChanneled( "foo", 1 );
-               $this->maintenance->outputChanneled( "bar", 1.0 );
-               $this->assertOutputPrePostShutdown( "foo\nbar", true );
-       }
-
-       function testOutputChanneledWOChannelIntermittentEmpty() {
-               $this->maintenance->outputChanneled( "foo" );
-               $this->maintenance->outputChanneled( "" );
-               $this->maintenance->outputChanneled( "bar" );
-               $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
-       }
-
-       function testOutputChanneledWOChannelIntermittentFalse() {
-               $this->maintenance->outputChanneled( "foo" );
-               $this->maintenance->outputChanneled( false );
-               $this->maintenance->outputChanneled( "bar" );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputChanneledWNullChannelIntermittentEmpty() {
-               $this->maintenance->outputChanneled( "foo", null );
-               $this->maintenance->outputChanneled( "", null );
-               $this->maintenance->outputChanneled( "bar", null );
-               $this->assertOutputPrePostShutdown( "foo\n\nbar\n", false );
-       }
-
-       function testOutputChanneledWNullChannelIntermittentFalse() {
-               $this->maintenance->outputChanneled( "foo", null );
-               $this->maintenance->outputChanneled( false, null );
-               $this->maintenance->outputChanneled( "bar", null );
-               $this->assertOutputPrePostShutdown( "foo\nbar\n", false );
-       }
-
-       function testOutputChanneledWChannelIntermittentEmpty() {
-               $this->maintenance->outputChanneled( "foo", "bazChannel" );
-               $this->maintenance->outputChanneled( "", "bazChannel" );
-               $this->maintenance->outputChanneled( "bar", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foobar", true );
+       /**
+        * @dataProvider provideOutputData
+        */
+       function testOutput( $outputs, $expected, $extraNL ) {
+               foreach ( $outputs as $data ) {
+                       if ( is_array( $data ) ) {
+                               list( $msg, $channel ) = $data;
+                       } else {
+                               $msg = $data;
+                               $channel = null;
+                       }
+                       $this->maintenance->output( $msg, $channel );
+               }
+               $this->assertOutputPrePostShutdown( $expected, $extraNL );
+       }
+
+       public function provideOutputData() {
+               return [
+                       [ [ "" ], "", false ],
+                       [ [ "foo" ], "foo", false ],
+                       [ [ "foo", "bar" ], "foobar", false ],
+                       [ [ "foo\n" ], "foo\n", false ],
+                       [ [ "foo\n\n" ], "foo\n\n", false ],
+                       [ [ "foo\nbar" ], "foo\nbar", false ],
+                       [ [ "foo\nbar\n" ], "foo\nbar\n", false ],
+                       [ [ "foo\n", "bar\n" ], "foo\nbar\n", false ],
+                       [ [ "", "foo", "", "\n", "ba", "", "r\n" ], "foo\nbar\n", false ],
+                       [ [ "", "foo", "", "\nb", "a", "", "r\n" ], "foo\nbar\n", false ],
+                       [ [ [ "foo", "bazChannel" ] ], "foo", true ],
+                       [ [ [ "foo\n", "bazChannel" ] ], "foo", true ],
+
+                       // If this test fails, note that output takes strings with double line
+                       // endings (although output's implementation in this situation calls
+                       // outputChanneled with a string ending in a nl ... which is not allowed
+                       // according to the documentation of outputChanneled)
+                       [ [ [ "foo\n\n", "bazChannel" ] ], "foo\n", true ],
+                       [ [ [ "foo\nbar", "bazChannel" ] ], "foo\nbar", true ],
+                       [ [ [ "foo\nbar\n", "bazChannel" ] ], "foo\nbar", true ],
+                       [
+                               [
+                                       [ "foo\n", "bazChannel" ],
+                                       [ "bar\n", "bazChannel" ],
+                               ],
+                               "foobar",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "", "bazChannel" ],
+                                       [ "foo", "bazChannel" ],
+                                       [ "", "bazChannel" ],
+                                       [ "\n", "bazChannel" ],
+                                       [ "ba", "bazChannel" ],
+                                       [ "", "bazChannel" ],
+                                       [ "r\n", "bazChannel" ],
+                               ],
+                               "foobar",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "", "bazChannel" ],
+                                       [ "foo", "bazChannel" ],
+                                       [ "", "bazChannel" ],
+                                       [ "\nb", "bazChannel" ],
+                                       [ "a", "bazChannel" ],
+                                       [ "", "bazChannel" ],
+                                       [ "r\n", "bazChannel" ],
+                               ],
+                               "foo\nbar",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", "bazChannel" ],
+                                       [ "bar", "bazChannel" ],
+                                       [ "qux", "quuxChannel" ],
+                                       [ "corge", "bazChannel" ],
+                               ],
+                               "foobar\nqux\ncorge",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", "bazChannel" ],
+                                       [ "bar\n", "bazChannel" ],
+                                       [ "qux\n", "quuxChannel" ],
+                                       [ "corge", "bazChannel" ],
+                               ],
+                               "foobar\nqux\ncorge",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", null ],
+                                       [ "bar", "bazChannel" ],
+                                       [ "qux", null ],
+                                       [ "quux", "bazChannel" ],
+                               ],
+                               "foobar\nquxquux",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", "bazChannel" ],
+                                       [ "bar", null ],
+                                       [ "qux", "bazChannel" ],
+                                       [ "quux", null ],
+                               ],
+                               "foo\nbarqux\nquux",
+                               false
+                       ],
+                       [
+                               [
+                                       [ "foo", 1 ],
+                                       [ "bar", 1.0 ],
+                               ],
+                               "foo\nbar",
+                               true
+                       ],
+                       [ [ "foo", "", "bar" ], "foobar", false ],
+                       [ [ "foo", false, "bar" ], "foobar", false ],
+                       [
+                               [
+                                       [ "qux", "quuxChannel" ],
+                                       "foo",
+                                       false,
+                                       "bar"
+                               ],
+                               "qux\nfoobar",
+                               false
+                       ],
+                       [
+                               [
+                                       [ "foo", "bazChannel" ],
+                                       [ "", "bazChannel" ],
+                                       [ "bar", "bazChannel" ],
+                               ],
+                               "foobar",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", "bazChannel" ],
+                                       [ false, "bazChannel" ],
+                                       [ "bar", "bazChannel" ],
+                               ],
+                               "foobar",
+                               true
+                       ],
+               ];
        }
 
-       function testOutputChanneledWChannelIntermittentFalse() {
-               $this->maintenance->outputChanneled( "foo", "bazChannel" );
-               $this->maintenance->outputChanneled( false, "bazChannel" );
-               $this->maintenance->outputChanneled( "bar", "bazChannel" );
-               $this->assertOutputPrePostShutdown( "foo\nbar", true );
+       /**
+        * @dataProvider provideOutputChanneledData
+        */
+       function testOutputChanneled( $outputs, $expected, $extraNL ) {
+               foreach ( $outputs as $data ) {
+                       if ( is_array( $data ) ) {
+                               list( $msg, $channel ) = $data;
+                       } else {
+                               $msg = $data;
+                               $channel = null;
+                       }
+                       $this->maintenance->outputChanneled( $msg, $channel );
+               }
+               $this->assertOutputPrePostShutdown( $expected, $extraNL );
+       }
+
+       public function provideOutputChanneledData() {
+               return [
+                       [ [ "" ], "\n", false ],
+                       [ [ "foo" ], "foo\n", false ],
+                       [ [ "foo", "bar" ], "foo\nbar\n", false ],
+                       [ [ "foo\nbar" ], "foo\nbar\n", false ],
+                       [ [ "", "foo", "", "\nb", "a", "", "r" ], "\nfoo\n\n\nb\na\n\nr\n", false ],
+                       [ [ [ "foo", "bazChannel" ] ], "foo", true ],
+                       [
+                               [
+                                       [ "foo\nbar", "bazChannel" ]
+                               ],
+                               "foo\nbar",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", "bazChannel" ],
+                                       [ "bar", "bazChannel" ],
+                               ],
+                               "foobar",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "", "bazChannel" ],
+                                       [ "foo", "bazChannel" ],
+                                       [ "", "bazChannel" ],
+                                       [ "\nb", "bazChannel" ],
+                                       [ "a", "bazChannel" ],
+                                       [ "", "bazChannel" ],
+                                       [ "r", "bazChannel" ],
+                               ],
+                               "foo\nbar",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", "bazChannel" ],
+                                       [ "bar", "bazChannel" ],
+                                       [ "qux", "quuxChannel" ],
+                                       [ "corge", "bazChannel" ],
+                               ],
+                               "foobar\nqux\ncorge",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", "bazChannel" ],
+                                       [ "bar", "bazChannel" ],
+                                       [ "qux", "quuxChannel" ],
+                                       [ "corge", "bazChannel" ],
+                               ],
+                               "foobar\nqux\ncorge",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", "bazChannel" ],
+                                       [ "bar", null ],
+                                       [ "qux", null ],
+                                       [ "corge", "bazChannel" ],
+                               ],
+                               "foo\nbar\nqux\ncorge",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", null ],
+                                       [ "bar", "bazChannel" ],
+                                       [ "qux", null ],
+                                       [ "quux", "bazChannel" ],
+                               ],
+                               "foo\nbar\nqux\nquux",
+                               true
+                       ],
+                       [
+                               [
+                                       [ "foo", "bazChannel" ],
+                                       [ "bar", null ],
+                                       [ "qux", "bazChannel" ],
+                                       [ "quux", null ],
+                               ],
+                               "foo\nbar\nqux\nquux\n",
+                               false
+                       ],
+                       [
+                               [
+                                       [ "foo", 1 ],
+                                       [ "bar", 1.0 ],
+                               ],
+                               "foo\nbar",
+                               true
+                       ],
+                       [ [ "foo", "", "bar" ], "foo\n\nbar\n", false ],
+                       [ [ "foo", false, "bar" ], "foo\nbar\n", false ],
+               ];
        }
 
        function testCleanupChanneledClean() {