Shell: skip null parameters
[lhc/web/wiklou.git] / tests / phpunit / includes / shell / CommandTest.php
index 81fae33..f7275e1 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use MediaWiki\Shell\Command;
+use Wikimedia\TestingAccessWrapper;
 
 /**
  * @group Shell
@@ -103,6 +104,16 @@ class CommandTest extends PHPUnit_Framework_TestCase {
                $this->assertRegExp( '/^.+no-such-file.*$/m', $result->getStderr() );
        }
 
+       /**
+        * Test that null values are skipped by params() and unsafeParams()
+        */
+       public function testNullsAreSkipped() {
+               $command = TestingAccessWrapper::newFromObject( new Command );
+               $command->params( 'echo', 'a', null, 'b' );
+               $command->unsafeParams( 'c', null, 'd' );
+               $this->assertEquals( "'echo' 'a' 'b' c d", $command->command );
+       }
+
        public function testT69870() {
                $commandLine = wfIsWindows()
                        // 333 = 331 + CRLF