From d635f13f25a9c11c26c88848829d389f1775b3b1 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 5 Apr 2024 17:57:06 +0200 Subject: [PATCH 1/4] Update Doctrine.php: Adding upgrade instructions (#29) --- src/Codeception/Module/Doctrine.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Codeception/Module/Doctrine.php b/src/Codeception/Module/Doctrine.php index 6a92475..a10de5f 100644 --- a/src/Codeception/Module/Doctrine.php +++ b/src/Codeception/Module/Doctrine.php @@ -38,10 +38,15 @@ use function var_export; /** + * Upgrading from Module "Doctrine2": + * * In your `composer.json`: Replace `"codeception/module-doctrine2"` with `"codeception/module-doctrine"` + * * In your `Acceptance.suite.yml`, `Functional.suite.yml`, and `Unit.suite.yml`: Replace `- Doctrine2:` with `- Doctrine:` + * * In any file in `Support/Helper/`: Change `$this->getModule('Doctrine2')` to `$this->getModule('Doctrine')` + * * Access the database using [Doctrine ORM](https://docs.doctrine-project.org/projects/doctrine-orm/en/latest/). * * When used with Symfony or Zend Framework 2, Doctrine's Entity Manager is automatically retrieved from Service Locator. - * Set up your `functional.suite.yml` like this: + * Set up your `Functional.suite.yml` like this: * * ```yaml * modules: From 2b880125d974fab1e5b91e786e3b27be14ee0b27 Mon Sep 17 00:00:00 2001 From: Dieter Beck Date: Sun, 28 Jul 2024 02:52:02 +0200 Subject: [PATCH 2/4] Declare nullable parameter types explicitly (#31) Implicit nullable parameter types will be deprecated in PHP 8.4 --- src/Codeception/Module/Doctrine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Codeception/Module/Doctrine.php b/src/Codeception/Module/Doctrine.php index a10de5f..eb6f865 100644 --- a/src/Codeception/Module/Doctrine.php +++ b/src/Codeception/Module/Doctrine.php @@ -192,7 +192,7 @@ public function _depends(): array return [DoctrineProvider::class => $this->dependencyMessage]; } - public function _inject(DoctrineProvider $dependentModule = null): void + public function _inject(?DoctrineProvider $dependentModule = null): void { $this->dependentModule = $dependentModule; } From db8866b6eeb85246bbf68c4f003a1b459fb5c831 Mon Sep 17 00:00:00 2001 From: Dieter Beck Date: Mon, 11 Nov 2024 17:44:51 +0100 Subject: [PATCH 3/4] Fix support for doctrine/dbal v2 (#32) * Allow version of doctrine/data-fixtures to allow installation of doctrine/dbal v2 in tests * Fix compatibility with doctrine/dbal v2 --- composer.json | 2 +- src/Codeception/Module/Doctrine.php | 8 +++++++- tests/unit/Codeception/Module/Doctrine2Test.php | 9 ++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 87fda24..c98274b 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require-dev": { "codeception/stub": "^4.1.3", "doctrine/annotations": "^2.0.1", - "doctrine/data-fixtures": "^1.7", + "doctrine/data-fixtures": "^1.6", "doctrine/orm": "^2.14 || ^3.0", "phpstan/phpstan": "^1.10.58", "symfony/cache": "^5.4.35 || ^6.4.3 || ^7.0", diff --git a/src/Codeception/Module/Doctrine.php b/src/Codeception/Module/Doctrine.php index eb6f865..35c79df 100644 --- a/src/Codeception/Module/Doctrine.php +++ b/src/Codeception/Module/Doctrine.php @@ -262,7 +262,13 @@ protected function retrieveEntityManager(): void ); } - $this->em->getConnection()->getNativeConnection(); + $connection = $this->em->getConnection(); + if (method_exists($connection, 'getNativeConnection')) { + $connection->getNativeConnection(); + } else { + // @phpstan-ignore-next-line + $connection->getWrappedConnection(); + } } /** diff --git a/tests/unit/Codeception/Module/Doctrine2Test.php b/tests/unit/Codeception/Module/Doctrine2Test.php index 5ef84f5..ad09560 100644 --- a/tests/unit/Codeception/Module/Doctrine2Test.php +++ b/tests/unit/Codeception/Module/Doctrine2Test.php @@ -71,7 +71,14 @@ protected function _setUp() require_once $dir . "/CircularRelations/C.php"; require_once $dir . '/EntityWithUuid.php'; - $connection = DriverManager::getConnection(['driver' => 'sqlite3', 'memory' => true]); + $sqliteDriver = 'sqlite3'; + // The driver "sqlite3" is only available as-of doctrine/dbal:3.5 + // Use "pdo_sqlite" for older versions + if (version_compare(InstalledVersions::getVersion('doctrine/dbal'), '3.5', '<')) { + $sqliteDriver = 'pdo_sqlite'; + } + + $connection = DriverManager::getConnection(['driver' => $sqliteDriver, 'memory' => true]); if (version_compare(InstalledVersions::getVersion('doctrine/orm'), '3', '>=')) { $this->em = new EntityManager( From ce890f055afdc3969a570eb6c7653122e66a20e6 Mon Sep 17 00:00:00 2001 From: Dieter Beck Date: Mon, 11 Nov 2024 17:45:36 +0100 Subject: [PATCH 4/4] PHP 8.4: Fix E_STRICT deprecation (#34) * Test against PHP 8.4 * PHP 8.4: Do not use deprecated constant E_STRICT --- .github/workflows/main.yml | 2 +- tests/unit.suite.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1525e16..c40fa75 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [8.1, 8.2, 8.3] + php: [8.1, 8.2, 8.3, 8.4] composer_flags: [ '', '--prefer-lowest' ] steps: diff --git a/tests/unit.suite.yml b/tests/unit.suite.yml index dc82ae8..5f0213b 100644 --- a/tests/unit.suite.yml +++ b/tests/unit.suite.yml @@ -1,2 +1,2 @@ -error_level: "E_ALL | E_STRICT" +error_level: "E_ALL" class_name: UnitTester