Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix PHP 8 tests running with wrong --php-version=/phpVersion= if not explicitly specified #10776

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use PHP_VERSION_ID instead of version_compare()
As we do elsewhere
  • Loading branch information
weirdan committed Mar 3, 2024
commit 87e2af43f52438e92d4079ba2ad5342523722040
5 changes: 2 additions & 3 deletions tests/Traits/InvalidCodeAnalysisTestTrait.php
Original file line number Diff line number Diff line change
@@ -11,10 +11,9 @@
use function strpos;
use function strtoupper;
use function substr;
use function version_compare;

use const PHP_OS;
use const PHP_VERSION;
use const PHP_VERSION_ID;

/**
* @psalm-type DeprecatedDataProviderArrayNotation = array{
@@ -53,7 +52,7 @@ public function testInvalidCode(
): void {
$test_name = $this->getTestName();
if (strpos($test_name, 'PHP80-') !== false) {
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
if (PHP_VERSION_ID < 8_00_00) {
$this->markTestSkipped('Test case requires PHP 8.0.');
}

7 changes: 3 additions & 4 deletions tests/Traits/ValidCodeAnalysisTestTrait.php
Original file line number Diff line number Diff line change
@@ -10,10 +10,9 @@
use function strpos;
use function strtoupper;
use function substr;
use function version_compare;

use const PHP_OS;
use const PHP_VERSION;
use const PHP_VERSION_ID;

trait ValidCodeAnalysisTestTrait
{
@@ -44,15 +43,15 @@ public function testValidCode(
): void {
$test_name = $this->getTestName();
if (strpos($test_name, 'PHP80-') !== false) {
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
if (PHP_VERSION_ID < 8_00_00) {
$this->markTestSkipped('Test case requires PHP 8.0.');
}

if ($php_version === null) {
$php_version = '8.0';
}
} elseif (strpos($test_name, 'PHP81-') !== false) {
if (version_compare(PHP_VERSION, '8.1.0', '<')) {
if (PHP_VERSION_ID < 8_01_00) {
$this->markTestSkipped('Test case requires PHP 8.1.');
}

Loading