1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

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
This commit is contained in:
Daniil Gentili 2024-03-19 13:47:01 +01:00 committed by GitHub
commit e8e1f47ddb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -25,6 +25,7 @@ use function tempnam;
use function unlink;
use const DIRECTORY_SEPARATOR;
use const PHP_BINARY;
/**
* Tests some of the most important use cases of the psalm and psalter commands, by launching a new
@ -116,7 +117,7 @@ class PsalmEndToEndTest extends TestCase
public function testPsalter(): void
{
$this->runPsalmInit();
(new Process(['php', $this->psalter, '--alter', '--issues=InvalidReturnType'], self::$tmpDir))->mustRun();
(new Process([PHP_BINARY, $this->psalter, '--alter', '--issues=InvalidReturnType'], self::$tmpDir))->mustRun();
$this->assertSame(0, $this->runPsalm([], self::$tmpDir)['CODE']);
}
@ -229,7 +230,7 @@ class PsalmEndToEndTest extends TestCase
file_put_contents(self::$tmpDir . '/src/psalm.xml', $psalmXmlContent);
$process = new Process(['php', $this->psalm, '--config=src/psalm.xml'], self::$tmpDir);
$process = new Process([PHP_BINARY, $this->psalm, '--config=src/psalm.xml'], self::$tmpDir);
$process->run();
$this->assertSame(2, $process->getExitCode());
$this->assertStringContainsString('InvalidReturnType', $process->getOutput());

View File

@ -8,6 +8,8 @@ use function array_merge;
use function array_unshift;
use function in_array;
use const PHP_BINARY;
trait PsalmRunnerTrait
{
private string $psalm = __DIR__ . '/../../psalm';
@ -37,9 +39,9 @@ trait PsalmRunnerTrait
// we run `php psalm` rather than just `psalm`.
if ($relyOnConfigDir) {
$process = new Process(array_merge(['php', $this->psalm, '-c=' . $workingDir . '/psalm.xml'], $args), null);
$process = new Process(array_merge([PHP_BINARY, $this->psalm, '-c=' . $workingDir . '/psalm.xml'], $args), null);
} else {
$process = new Process(array_merge(['php', $this->psalm], $args), $workingDir);
$process = new Process(array_merge([PHP_BINARY, $this->psalm], $args), $workingDir);
}
if (!$shouldFail) {