From ecf13f0aef5d0528c8ca3bed230e889602c1187b Mon Sep 17 00:00:00 2001 From: Synida Date: Tue, 20 May 2025 14:07:29 +0300 Subject: [PATCH 1/2] FIX: driver compatibility with mongoDB 5.0+ + compatibility fix with phpunit 10+ due to codeception/codeception 5.0.8+ requirement + locking min behat/gherkin package version for dev requirement due to compatibility issues between codeception 5.0.8 and 5.2.1 + FIX: MongoDb driver is incompatible with any mongoDB versions as of 5.0, since the mongo shell script was completely removed and replaced with mongosh + NOTE: testCleanupDirty test function might be broken for a while as it wasn't changed. It expects an early cleanup not to be executed, however nothing indicates that it should change from it's default value, so shouldCleanup returns true, which initiates a cleanup. --- composer.json | 5 +++-- src/Codeception/Lib/Driver/MongoDb.php | 2 +- tests/unit/Codeception/Module/MongoDbTest.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 3e5848d..acaa9f5 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "minimum-stability": "RC", "require": { "php": "^8.0", - "codeception/codeception": "^5.0", + "codeception/codeception": "^5.0.8", "mongodb/mongodb": "^1.12" }, "autoload": { @@ -25,6 +25,7 @@ "classmap-authoritative": true }, "require-dev": { - "codeception/stub": "^4.0" + "codeception/stub": "^4.0", + "behat/gherkin": "^4.12" } } diff --git a/src/Codeception/Lib/Driver/MongoDb.php b/src/Codeception/Lib/Driver/MongoDb.php index 101fa6b..24c5521 100644 --- a/src/Codeception/Lib/Driver/MongoDb.php +++ b/src/Codeception/Lib/Driver/MongoDb.php @@ -112,7 +112,7 @@ public function cleanup(): void public function load(string $dumpFile): void { $cmd = sprintf( - 'mongo %s %s%s', + 'mongosh %s %s%s', $this->host . '/' . $this->dbName, $this->createUserPasswordCmdString(), escapeshellarg($dumpFile) diff --git a/tests/unit/Codeception/Module/MongoDbTest.php b/tests/unit/Codeception/Module/MongoDbTest.php index 443e7ff..6c119fc 100644 --- a/tests/unit/Codeception/Module/MongoDbTest.php +++ b/tests/unit/Codeception/Module/MongoDbTest.php @@ -41,7 +41,7 @@ protected function _setUp() $this->markTestSkipped('MongoDB is not installed'); } - $cleanupDirty = in_array('cleanup-dirty', $this->getGroups()); + $cleanupDirty = in_array('cleanup-dirty', $this->groups()); $config = $this->mongoConfig + ['cleanup' => $cleanupDirty ? 'dirty' : true]; $client = new \MongoDB\Client(); From a90ea1ada34f8aa645daaf81b1a2b58e65427d1f Mon Sep 17 00:00:00 2001 From: Synida Date: Wed, 21 May 2025 04:02:10 +0300 Subject: [PATCH 2/2] Dropping support for php 8.0 + Dropping support for php 8.0 as it isn't a supported version as of 26 Nov 2023(https://www.php.net/eol.php) + Workflows tests support for currently supported php versions(8.1, 8.2, 8.3, 8.4) --- .github/workflows/main.yml | 2 +- composer.json | 2 +- readme.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be19e5e..0054fa4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - php: [8.0, 8.1] + php: [8.1, 8.2, 8.3, 8.4] steps: - name: Checkout code diff --git a/composer.json b/composer.json index acaa9f5..2e57567 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ ], "minimum-stability": "RC", "require": { - "php": "^8.0", + "php": "^8.1", "codeception/codeception": "^5.0.8", "mongodb/mongodb": "^1.12" }, diff --git a/readme.md b/readme.md index ff01027..e03948e 100644 --- a/readme.md +++ b/readme.md @@ -15,7 +15,7 @@ composer require "codeception/module-mongodb" --dev ## Requirements -* `PHP 8.0` or higher. +* `PHP 8.1` or higher. ## Documentation