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..32ee7ad 100644 --- a/tests/unit/Codeception/Module/Doctrine2Test.php +++ b/tests/unit/Codeception/Module/Doctrine2Test.php @@ -71,7 +71,12 @@ protected function _setUp() require_once $dir . "/CircularRelations/C.php"; require_once $dir . '/EntityWithUuid.php'; - $connection = DriverManager::getConnection(['driver' => 'sqlite3', 'memory' => true]); + $sqliteDriver = 'sqlite3'; + if (version_compare(InstalledVersions::getVersion('doctrine/orm'), '3.5', '<')) { + $sqliteDriver = 'pdo_sqlite'; + } + + $connection = DriverManager::getConnection(['driver' => $sqliteDriver, 'memory' => true]); if (version_compare(InstalledVersions::getVersion('doctrine/orm'), '3', '>=')) { $this->em = new EntityManager(