]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - tests/phpunit/includes/shell/ShellTest.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / tests / phpunit / includes / shell / ShellTest.php
diff --git a/tests/phpunit/includes/shell/ShellTest.php b/tests/phpunit/includes/shell/ShellTest.php
new file mode 100644 (file)
index 0000000..7c96c3c
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+use MediaWiki\Shell\Shell;
+
+/**
+ * @group Shell
+ */
+class ShellTest extends PHPUnit_Framework_TestCase {
+       public function testIsDisabled() {
+               $this->assertInternalType( 'bool', Shell::isDisabled() ); // sanity
+       }
+
+       /**
+        * @dataProvider provideEscape
+        */
+       public function testEscape( $args, $expected ) {
+               if ( wfIsWindows() ) {
+                       $this->markTestSkipped( 'This test requires a POSIX environment.' );
+               }
+               $this->assertSame( $expected, call_user_func_array( [ Shell::class, 'escape' ], $args ) );
+       }
+
+       public function provideEscape() {
+               return [
+                       'simple' => [ [ 'true' ], "'true'" ],
+                       'with args' => [ [ 'convert', '-font', 'font name' ], "'convert' '-font' 'font name'" ],
+                       'array' => [ [ [ 'convert', '-font', 'font name' ] ], "'convert' '-font' 'font name'" ],
+                       'skip nulls' => [ [ 'ls', null ], "'ls'" ],
+               ];
+       }
+}