Skip to content

Commit d86e9ca

Browse files
committed
Fix compatibility with doctrine/dbal v2
1 parent 1764988 commit d86e9ca

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Codeception/Module/Doctrine.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,13 @@ protected function retrieveEntityManager(): void
262262
);
263263
}
264264

265-
$this->em->getConnection()->getNativeConnection();
265+
$connection = $this->em->getConnection();
266+
if (method_exists($connection, 'getNativeConnection')) {
267+
$connection->getNativeConnection();
268+
} else {
269+
// @phpstan-ignore-next-line
270+
$connection->getWrappedConnection();
271+
}
266272
}
267273

268274
/**

tests/unit/Codeception/Module/Doctrine2Test.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ protected function _setUp()
7171
require_once $dir . "/CircularRelations/C.php";
7272
require_once $dir . '/EntityWithUuid.php';
7373

74-
$connection = DriverManager::getConnection(['driver' => 'sqlite3', 'memory' => true]);
74+
$sqliteDriver = 'sqlite3';
75+
if (version_compare(InstalledVersions::getVersion('doctrine/orm'), '3.5', '<')) {
76+
$sqliteDriver = 'pdo_sqlite';
77+
}
78+
79+
$connection = DriverManager::getConnection(['driver' => $sqliteDriver, 'memory' => true]);
7580

7681
if (version_compare(InstalledVersions::getVersion('doctrine/orm'), '3', '>=')) {
7782
$this->em = new EntityManager(

0 commit comments

Comments
 (0)