aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/shell/ShellTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/shell/ShellTest.php')
-rw-r--r--tests/phpunit/includes/shell/ShellTest.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/phpunit/includes/shell/ShellTest.php b/tests/phpunit/includes/shell/ShellTest.php
new file mode 100644
index 000000000000..1e91074fd400
--- /dev/null
+++ b/tests/phpunit/includes/shell/ShellTest.php
@@ -0,0 +1,30 @@
+<?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'" ],
+ ];
+ }
+}