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/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 6a92475..35c79df 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: @@ -187,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; } @@ -257,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.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 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(