Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
32 lines (26 loc) · 1.19 KB

File metadata and controls

32 lines (26 loc) · 1.19 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<?php
use WP_CLI\Process;
use WP_CLI\Tests\TestCase;
use WP_CLI\Utils;
use PHPUnit\Framework\Attributes\DataProvider;
class ProcessTest extends TestCase {
/**
* @dataProvider data_process_env
*/
#[DataProvider( 'data_process_env' )] // phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPUnitAttributeFound
public function test_process_env( $cmd_prefix, $env, $expected_env_vars, $expected_out ): void {
$code = vsprintf( str_repeat( 'echo getenv( \'%s\' );', count( $expected_env_vars ) ), $expected_env_vars );
$cmd = $cmd_prefix . ' ' . escapeshellarg( Utils\get_php_binary() ) . ' -r ' . escapeshellarg( $code );
$process_run = Process::create( $cmd, null /*cwd*/, $env )->run();
$this->assertSame( $process_run->stdout, $expected_out );
}
public static function data_process_env(): array {
return [
[ '', [], [], '' ],
[ 'ENV=blah', [], [ 'ENV' ], 'blah' ],
[ 'ENV="blah blah"', [], [ 'ENV' ], 'blah blah' ],
[ 'ENV_1="blah1 blah1" ENV_2="blah2" ENV_3=blah3', [ 'ENV' => 'in' ], [ 'ENV', 'ENV_1', 'ENV_2', 'ENV_3' ], 'inblah1 blah1blah2blah3' ],
[ 'ENV=blah', [ 'ENV_1' => 'in1', 'ENV_2' => 'in2' ], [ 'ENV_1', 'ENV_2', 'ENV' ], 'in1in2blah' ],
];
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.