5use Wikimedia\TestingAccessWrapper;
13 use MediaWikiCoversValidator;
17 $this->markTestSkipped(
'This test requires a POSIX environment.' );
30 $this->assertSame( $expectedExitCode, $result->getExitCode() );
31 $this->assertSame( $expectedOutput, $result->getStdout() );
36 'success status' => [
'success_status.php', [], 0,
'' ],
37 'failure status' => [
'failure_status.php', [], 1,
'' ],
38 'output' => [
'echo_args.php', [
'x',
'>',
'y' ], 0,
'x > y' ],
46 ->environment( [
'FOO' =>
'bar' ] )
48 $this->assertSame(
"bar", $result->getStdout() );
55 ->unsafeParams(
'ThisIsStderr',
'1>&2' )
58 $this->assertNotContains(
'ThisIsStderr', $result->getStdout() );
59 $this->assertEquals(
"ThisIsStderr", $result->getStderr() );
69 ->params(
'bash',
'-c',
'echo ThisIsStderr 1>&2' )
70 ->includeStderr(
true )
73 $this->assertEquals(
"ThisIsStderr\n", $result->getStdout() );
74 $this->assertNull( $result->getStderr() );
83 $this->assertSame(
'correct stdout', $result->getStdout() );
84 $this->assertSame(
null, $result->getStderr() );
88 [
'correct stdout ',
'correct stderr ' ]
93 $this->assertRegExp(
'/correct stdout/m', $result->getStdout() );
94 $this->assertRegExp(
'/correct stderr/m', $result->getStdout() );
95 $this->assertSame(
null, $result->getStderr() );
99 [
'correct stdout',
'correct stderr' ]
103 $this->assertSame(
'correct stdout', $result->getStdout() );
104 $this->assertSame(
'correct stderr', $result->getStderr() );
112 $command->params(
'echo',
'a',
null,
'b' );
113 $command->unsafeParams(
'c',
null,
'd' );
116 $this->assertEquals(
'"echo" "a" "b" c d',
$command->command );
118 $this->assertEquals(
"'echo' 'a' 'b' c d",
$command->command );
130 for ( $i = 0; $i < 10; $i++ ) {
135 $this->assertEquals( 333333, strlen(
$output ) );
141 return $level === Psr\Log\LogLevel::ERROR ?
'1' :
null;
144 $command->setLogger( $logger );
145 $command->unsafeParams(
'ThisIsStderr',
'1>&2' );
147 $this->assertEmpty( $logger->getBuffer() );
150 $command->setLogger( $logger );
152 $command->unsafeParams(
'ThisIsStderr',
'1>&2' );
154 $this->assertSame( 1, count( $logger->getBuffer() ) );
155 $this->assertSame( trim( $logger->getBuffer()[0][2][
'error'] ),
'ThisIsStderr' );
165 $this->assertSame(
'abc', $result->getStdout() );
169 $command->input( str_repeat(
'!', 1000000 ) );
171 $this->assertSame( 1000000, strlen( $result->getStdout() ) );
177 $this->assertSame(
'', $result->getStdout() );
187 $command->restrict( Shell::RESTRICT_DEFAULT );
189 $command->restrict( Shell::RESTRICT_NONE );
190 $this->assertSame( 0,
$command->restrictions );
210 . DIRECTORY_SEPARATOR
212 . DIRECTORY_SEPARATOR
218 $command->limits( [
'memory' => 0 ] );
wfIsWindows()
Check if the operating system is Windows.
\MediaWiki\Shell\Command Shell
testDisablingRestrictions()
Ensure that it's possible to disable the default shell restrictions.
getPhpCommand( $fileName, array $args=[])
Creates a command that will execute one of the PHP test scripts by its file name, using the current P...
testNullsAreSkipped()
Test that null values are skipped by params() and unsafeParams()
testExecute( $command, $args, $expectedExitCode, $expectedOutput)
provideExecute
A logger that may be configured to either buffer logs or to print them to the output where PHPUnit wi...
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true