1
0
mirror of synced 2025-02-10 17:29:27 +03:00

Allow passing a connection while creating an entity manager

Also removing unsed arguments.
This commit is contained in:
Luís Cobucci 2017-06-12 20:03:11 +02:00
parent 1bf884970f
commit 99df158fc8
No known key found for this signature in database
GPG Key ID: EC61C5F01750ED3C

View File

@ -3,6 +3,7 @@
namespace Doctrine\Tests; namespace Doctrine\Tests;
use Doctrine\Common\Cache\ArrayCache; use Doctrine\Common\Cache\ArrayCache;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\PDOSqlite\Driver as SqliteDriver; use Doctrine\DBAL\Driver\PDOSqlite\Driver as SqliteDriver;
use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\Logging\DebugStack;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
@ -674,12 +675,11 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
/** /**
* Gets an EntityManager for testing purposes. * Gets an EntityManager for testing purposes.
* *
* @param \Doctrine\ORM\Configuration $config The Configuration to pass to the EntityManager. * @return EntityManager
* @param \Doctrine\Common\EventManager $eventManager The EventManager to pass to the 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 // NOTE: Functional tests use their own shared metadata cache, because
// the actual database platform used during execution has effect on some // the actual database platform used during execution has effect on some
// metadata mapping behaviors (like the choice of the ID generation). // metadata mapping behaviors (like the choice of the ID generation).
@ -732,13 +732,17 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
$this->isSecondLevelCacheEnabled = true; $this->isSecondLevelCacheEnabled = true;
} }
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver( $config->setMetadataDriverImpl(
[ $config->newDefaultAnnotationDriver(
realpath(__DIR__ . '/Models/Cache'), [
realpath(__DIR__ . '/Models/GeoNames') realpath(__DIR__ . '/Models/Cache'),
], true)); realpath(__DIR__ . '/Models/GeoNames')
],
true
)
);
$conn = static::$_sharedConn; $conn = $connection ?: static::$_sharedConn;
$conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack); $conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack);
// get rid of more global state // get rid of more global state