2016-11-03 00:27:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use MediaWiki\Shell\Shell;
|
|
|
|
|
|
|
|
|
|
/**
|
2017-12-09 06:08:28 +00:00
|
|
|
* @covers \MediaWiki\Shell\Shell
|
2016-11-03 00:27:15 +00:00
|
|
|
* @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'" ],
|
2017-11-29 02:51:25 +00:00
|
|
|
'skip nulls' => [ [ 'ls', null ], "'ls'" ],
|
2016-11-03 00:27:15 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|