summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/GlobalFunctions/wfEscapeShellArgTest.php
blob: cb334d2fd282aff7a0fd745cce5e68506f8ba7c3 (plain)
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 MediaWikiTestCase {
	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( array( 'foo', 'bar', 'baz' ) );

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