1
0
mirror of synced 2025-01-31 20:41:44 +03:00

Fixing build using a dedicated in-memory connection to stub out two real connections for DB-access checks

This commit is contained in:
Marco Pivetta 2015-01-17 07:58:35 +01:00
parent 074ec358ab
commit f6445d5a3e

View File

@ -4,15 +4,14 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\Logging\DebugStack;
use Doctrine\DBAL\Logging\SQLLogger; use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\ORM\Configuration; use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\Tools\ToolsException;
use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Tests\Models\Generic\DateTimeModel;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
use Doctrine\Tests\TestUtil;
class MergeProxiesTest extends OrmFunctionalTestCase class MergeProxiesTest extends OrmFunctionalTestCase
{ {
@ -21,12 +20,9 @@ class MergeProxiesTest extends OrmFunctionalTestCase
*/ */
protected function setUp() protected function setUp()
{ {
parent::setUp(); $this->useModelSet('generic');
try { parent::setUp();
$this->_schemaTool->createSchema(array($this->_em->getClassMetadata(DateTimeModel::CLASSNAME)));
} catch (ToolsException $ignored) {
}
} }
/** /**
@ -220,18 +216,20 @@ class MergeProxiesTest extends OrmFunctionalTestCase
true true
)); ));
$connection = TestUtil::getConnection(); // always runs on sqlite to prevent multi-connection race-conditions with the test suite
// multi-connection is not relevant for the purpose of checking locking here, but merely
// to stub out DB-level access and intercept it
$connection = DriverManager::getConnection(array(
'driver' => 'pdo_sqlite',
'memory' => true
));
$connection->getConfiguration()->setSQLLogger($logger); $connection->getConfiguration()->setSQLLogger($logger);
$entityManager = EntityManager::create($connection, $config); $entityManager = EntityManager::create($connection, $config);
try { (new SchemaTool($entityManager))
(new SchemaTool($entityManager)) ->createSchema([$this->_em->getClassMetadata(DateTimeModel::CLASSNAME)]);
->createSchema([$this->_em->getClassMetadata(DateTimeModel::CLASSNAME)]);
} catch (ToolsException $ignored) {
// tables were already created
}
return $entityManager; return $entityManager;
} }