Skip to content

Commit

Permalink
Fix compatibility with doctrine/dbal v2
Browse files Browse the repository at this point in the history
  • Loading branch information
W0rma committed Jul 29, 2024
1 parent 1764988 commit d86e9ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Codeception/Module/Doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

/**
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/Codeception/Module/Doctrine2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d86e9ca

Please sign in to comment.