Skip to content

Commit 2b16ce4

Browse files
authored
Expect the resolved Composer binary path in ComposerPharTest (#262)
1 parent 4db452c commit 2b16ce4

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎tests/phpunit/ComposerPharTest.php‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,24 @@ public function test_phar_command_and_php_arguments() {
3838
$binary = $this->directory . '/composer.phar';
3939
putenv( 'WP_CLI_COMPOSER_BINARY=' . $binary );
4040
putenv( 'WP_CLI_PHP_ARGS=-d memory_limit=123M' );
41+
// The override is resolved with realpath(), e.g. /var to /private/var on macOS, or 8.3 short names on Windows.
42+
$resolved = (string) realpath( $binary );
4143
$composer = new ComposerPhar();
4244
$command = $composer->command( [ 'update', 'vendor/package:^1.0' ], $this->directory . '/with spaces', true );
4345
$this->assertSame(
44-
Utils\esc_cmd( '%s', WP_CLI::get_php_binary() ) . ' -d memory_limit=123M ' . Utils\esc_cmd( '%s', $binary ) . ' ' . implode( ' ', array_map( 'escapeshellarg', [ 'update', 'vendor/package:^1.0', '--working-dir=' . $this->directory . '/with spaces', '--no-interaction', '--no-ansi', '--no-progress', '--quiet' ] ) ),
46+
Utils\esc_cmd( '%s', WP_CLI::get_php_binary() ) . ' -d memory_limit=123M ' . Utils\esc_cmd( '%s', $resolved ) . ' ' . implode( ' ', array_map( 'escapeshellarg', [ 'update', 'vendor/package:^1.0', '--working-dir=' . $this->directory . '/with spaces', '--no-interaction', '--no-ansi', '--no-progress', '--quiet' ] ) ),
4547
$command
4648
);
4749
$argv = $composer->run_json( [ 'outdated', '--format=json' ], $this->directory );
48-
$this->assertSame( [ $binary, 'outdated', '--format=json', '--working-dir=' . $this->directory, '--no-interaction', '--no-ansi' ], $argv );
50+
$this->assertSame( [ $resolved, 'outdated', '--format=json', '--working-dir=' . $this->directory, '--no-interaction', '--no-ansi' ], $argv );
4951
}
5052

5153
public function test_executable_does_not_use_php_arguments() {
5254
$binary = $this->directory . '/composer';
5355
putenv( 'WP_CLI_COMPOSER_BINARY=' . $binary );
5456
putenv( 'WP_CLI_PHP_ARGS=-d memory_limit=123M' );
5557
$command = ( new ComposerPhar() )->command( [ 'update' ], $this->directory );
56-
$this->assertSame( 0, strpos( $command, Utils\esc_cmd( '%s', $binary ) . ' ' ) );
58+
$this->assertSame( 0, strpos( $command, Utils\esc_cmd( '%s', (string) realpath( $binary ) ) . ' ' ) );
5759
$this->assertFalse( strpos( $command, 'memory_limit' ) );
5860
}
5961

0 commit comments

Comments
 (0)