Skip to content

Commit e8e1f47

Browse files
authored
Merge pull request #10842 from kkmuffme/fix-tests-using-other-than-called-from-php-version
fix tests running with other than called PHP binary if called with a non-default PHP binary
2 parents 4ea41cb + 8815463 commit e8e1f47

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

tests/EndToEnd/PsalmEndToEndTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use function unlink;
2626

2727
use const DIRECTORY_SEPARATOR;
28+
use const PHP_BINARY;
2829

2930
/**
3031
* Tests some of the most important use cases of the psalm and psalter commands, by launching a new
@@ -116,7 +117,7 @@ public function testAlter(): void
116117
public function testPsalter(): void
117118
{
118119
$this->runPsalmInit();
119-
(new Process(['php', $this->psalter, '--alter', '--issues=InvalidReturnType'], self::$tmpDir))->mustRun();
120+
(new Process([PHP_BINARY, $this->psalter, '--alter', '--issues=InvalidReturnType'], self::$tmpDir))->mustRun();
120121
$this->assertSame(0, $this->runPsalm([], self::$tmpDir)['CODE']);
121122
}
122123

@@ -229,7 +230,7 @@ public function testLegacyConfigWithoutresolveFromConfigFile(): void
229230

230231
file_put_contents(self::$tmpDir . '/src/psalm.xml', $psalmXmlContent);
231232

232-
$process = new Process(['php', $this->psalm, '--config=src/psalm.xml'], self::$tmpDir);
233+
$process = new Process([PHP_BINARY, $this->psalm, '--config=src/psalm.xml'], self::$tmpDir);
233234
$process->run();
234235
$this->assertSame(2, $process->getExitCode());
235236
$this->assertStringContainsString('InvalidReturnType', $process->getOutput());

tests/EndToEnd/PsalmRunnerTrait.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use function array_unshift;
99
use function in_array;
1010

11+
use const PHP_BINARY;
12+
1113
trait PsalmRunnerTrait
1214
{
1315
private string $psalm = __DIR__ . '/../../psalm';
@@ -37,9 +39,9 @@ private function runPsalm(
3739
// we run `php psalm` rather than just `psalm`.
3840

3941
if ($relyOnConfigDir) {
40-
$process = new Process(array_merge(['php', $this->psalm, '-c=' . $workingDir . '/psalm.xml'], $args), null);
42+
$process = new Process(array_merge([PHP_BINARY, $this->psalm, '-c=' . $workingDir . '/psalm.xml'], $args), null);
4143
} else {
42-
$process = new Process(array_merge(['php', $this->psalm], $args), $workingDir);
44+
$process = new Process(array_merge([PHP_BINARY, $this->psalm], $args), $workingDir);
4345
}
4446

4547
if (!$shouldFail) {

0 commit comments

Comments
 (0)