wiki.techinc.nl/tests/phpunit/unit/includes/GlobalFunctions/wfEscapeShellArgTest.php
Amir Sarabadani 06f645c453 Load GlobalFunctions.php to tests/phpunit/bootstrap.php
That mostly enables testing global functions

Bug: T87781
Change-Id: Ib42c56a67926ebcdba53f4c6c54a5bff98cb77a3
2019-07-14 01:28:07 +02:00

43 lines
868 B
PHP

<?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 );
}
}