From 99df158fc8369fbca52568901bc19b734c98c4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Mon, 12 Jun 2017 20:03:11 +0200 Subject: [PATCH] Allow passing a connection while creating an entity manager Also removing unsed arguments. --- .../Doctrine/Tests/OrmFunctionalTestCase.php | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index 5716f2a50..2a5f45264 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests; use Doctrine\Common\Cache\ArrayCache; +use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\PDOSqlite\Driver as SqliteDriver; use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\Types\Type; @@ -674,12 +675,11 @@ abstract class OrmFunctionalTestCase extends OrmTestCase /** * Gets an EntityManager for testing purposes. * - * @param \Doctrine\ORM\Configuration $config The Configuration to pass to the EntityManager. - * @param \Doctrine\Common\EventManager $eventManager The EventManager to pass to the EntityManager. + * @return EntityManager * - * @return \Doctrine\ORM\EntityManager + * @throws \Doctrine\ORM\ORMException */ - protected function _getEntityManager($config = null, $eventManager = null) { + protected function _getEntityManager(Connection $connection = null) { // NOTE: Functional tests use their own shared metadata cache, because // the actual database platform used during execution has effect on some // metadata mapping behaviors (like the choice of the ID generation). @@ -732,13 +732,17 @@ abstract class OrmFunctionalTestCase extends OrmTestCase $this->isSecondLevelCacheEnabled = true; } - $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver( - [ - realpath(__DIR__ . '/Models/Cache'), - realpath(__DIR__ . '/Models/GeoNames') - ], true)); + $config->setMetadataDriverImpl( + $config->newDefaultAnnotationDriver( + [ + realpath(__DIR__ . '/Models/Cache'), + realpath(__DIR__ . '/Models/GeoNames') + ], + true + ) + ); - $conn = static::$_sharedConn; + $conn = $connection ?: static::$_sharedConn; $conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack); // get rid of more global state