aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/GlobalFunctions/wfEscapeShellArgTest.php
blob: d86b3979b560f4f7fe6f5f0f25af89956626745d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

/**
 * @group GlobalFunctions
 * @covers ::wfEscapeShellArg
 */
class WfEscapeShellArgTest extends MediaWikiUnitTestCase {
	public function testSingleInput() {
		if ( wfIsWindows() ) {
			$expected = '"blah"';
		} else {
			$expected = "'blah'";
		}

		$actual = wfEscapeShellArg( 'blah' );

		$this->assertEquals( $expected, $actual );
	}

	public function testMultipleArgs() {
		if ( wfIsWindows() ) {
			$expected = '"foo" "bar" "baz"';
		} else {
			$expected = "'foo' 'bar' 'baz'";
		}

		$actual = wfEscapeShellArg( 'foo', 'bar', 'baz' );

		$this->assertEquals( $expected, $actual );
	}

	public function testMultipleArgsAsArray() {
		if ( wfIsWindows() ) {
			$expected = '"foo" "bar" "baz"';
		} else {
			$expected = "'foo' 'bar' 'baz'";
		}

		$actual = wfEscapeShellArg( [ 'foo', 'bar', 'baz' ] );

		$this->assertEquals( $expected, $actual );
	}
}