Skip to content

Commit

Permalink
PHPLIB-1502: Test with PHP 8.4 (#1484)
Browse files Browse the repository at this point in the history
* PHPLIB-1502: Test with PHP 8.4

* Remove psalm from dependencies on PHP 8.4

* Suppress deprecations in tests expecting no output

* Skip test failing due to PHPUnit deprecations

* Skip failing test on PHP 8.4
  • Loading branch information
alcaeus authored Oct 16, 2024
1 parent 96ab516 commit e1cef70
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .evergreen/config/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ functions:
working_dir: "src"
script: |
${PREPARE_SHELL}
file="${PROJECT_DIRECTORY}/.evergreen/install-composer.sh"
# Don't use ${file} syntax here because evergreen treats it as an empty expansion.
[ -f "$file" ] && DEPENDENCIES=${DEPENDENCIES} bash $file || echo "$file not available, skipping"
DEPENDENCIES=${DEPENDENCIES} \
PHP_VERSION=${PHP_VERSION} \
bash ${PROJECT_DIRECTORY}/.evergreen/install-composer.sh
"start load balancer":
- command: shell.exec
Expand Down
5 changes: 4 additions & 1 deletion .evergreen/config/generate-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

// Supported PHP versions. Add new versions to the beginning of the list
$modernPhpVersions = [
'8.4',
'8.3',
'8.2',
'8.1',
Expand All @@ -13,7 +14,9 @@
];
$supportedPhpVersions = array_merge($modernPhpVersions, $legacyPhpVersions);

$latestPhpVersion = max($supportedPhpVersions);
// TODO: use max() once PHP 8.4 is stable
//$latestPhpVersion = max($supportedPhpVersions);
$latestPhpVersion = '8.3';
$lowestPhpVersion = min($supportedPhpVersions);

// Supported MongoDB versions. Add new versions after "rapid"
Expand Down
10 changes: 10 additions & 0 deletions .evergreen/config/generated/build/build-extension-next-minor.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions .evergreen/config/generated/build/build-extension.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions .evergreen/config/generated/test-variant/modern-php-full.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .evergreen/install-composer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ php --ri mongodb

install_composer

# Remove psalm as it's not compatible with PHP 8.4: https://github.com/vimeo/psalm/pull/10928
if [ "$PHP_VERSION" == "8.4" ]; then
php composer.phar remove --no-update --dev vimeo/psalm
fi

php composer.phar update $COMPOSER_FLAGS
6 changes: 6 additions & 0 deletions tests/GridFS/BucketFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,9 @@ public function testDanglingOpenWritableStream(): void
$code = <<<'PHP'
require '%s';
require '%s';
// Don't report deprecations - if the issue exists this code will
// result in a fatal error
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
$client = MongoDB\Tests\FunctionalTestCase::createTestClient();
$database = $client->selectDatabase(getenv('MONGODB_DATABASE') ?: 'phplib_test');
$gridfs = $database->selectGridFSBucket();
Expand Down Expand Up @@ -903,6 +906,9 @@ public function testDanglingOpenWritableStreamWithGlobalStreamWrapperAlias(): vo
$code = <<<'PHP'
require '%s';
require '%s';
// Don't report deprecations - if the issue exists this code will
// result in a fatal error
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
$client = MongoDB\Tests\FunctionalTestCase::createTestClient();
$database = $client->selectDatabase(getenv('MONGODB_DATABASE') ?: 'phplib_test');
$database->selectGridFSBucket()->registerGlobalStreamWrapperAlias('alias');
Expand Down
6 changes: 6 additions & 0 deletions tests/Model/CodecCursorFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
use MongoDB\Model\CodecCursor;
use MongoDB\Tests\FunctionalTestCase;

use function phpversion;
use function restore_error_handler;
use function set_error_handler;
use function version_compare;

use const E_DEPRECATED;
use const E_USER_DEPRECATED;
Expand All @@ -25,6 +27,10 @@ public function setUp(): void

public function testSetTypeMap(): void
{
if (version_compare(phpversion(), '8.4', '>=')) {
$this->markTestIncomplete('Test fails on PHP 8.4 due to deprecations');
}

$collection = self::createTestClient()->selectCollection($this->getDatabaseName(), $this->getCollectionName());
$cursor = $collection->find();

Expand Down
6 changes: 6 additions & 0 deletions tests/UnifiedSpecTests/Constraint/MatchesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
use stdClass;

use function hex2bin;
use function phpversion;
use function preg_quote;
use function version_compare;

class MatchesTest extends FunctionalTestCase
{
Expand Down Expand Up @@ -69,6 +71,10 @@ public function testOperatorExists(): void

public function testOperatorType(): void
{
if (version_compare(phpversion(), '8.4', '>=')) {
$this->markTestIncomplete('Test fails on PHP 8.4 due to deprecations');
}

$c = new Matches(['x' => ['$$type' => 'string']]);
$this->assertResult(true, $c, ['x' => 'foo'], 'string matches string type');
$this->assertResult(false, $c, ['x' => 1], 'integer does not match string type');
Expand Down

0 comments on commit e1cef70

Please sign in to comment.