Commit 2a9886af authored by romanb's avatar romanb

[2.0] Fixed connection sharing when Functional DBAL or ORM tests are run standalone.

parent acec85a4
......@@ -4,15 +4,19 @@ namespace Doctrine\Tests;
class DbalFunctionalTestCase extends DbalTestCase
{
/* Shared connection when a TestCase is run alone (outside of it's functional suite) */
private static $_sharedConn;
protected $_conn;
protected function setUp()
{
if ( ! isset($this->_conn)) {
if ( ! isset($this->sharedFixture['conn'])) {
$this->sharedFixture['conn'] = TestUtil::getConnection();
}
if (isset($this->sharedFixture['conn'])) {
$this->_conn = $this->sharedFixture['conn'];
} else {
if ( ! isset(self::$_sharedConn)) {
self::$_sharedConn = TestUtil::getConnection();
}
$this->_conn = self::$_sharedConn;
}
}
}
\ No newline at end of file
......@@ -14,6 +14,9 @@ class OrmFunctionalTestCase extends OrmTestCase
/* The query cache shared between all functional tests. */
private static $_queryCacheImpl = null;
/* Shared connection when a TestCase is run alone (outside of it's functional suite) */
private static $_sharedConn;
/** The EntityManager for this testcase. */
protected $_em;
......@@ -79,8 +82,12 @@ class OrmFunctionalTestCase extends OrmTestCase
protected function setUp()
{
$forceCreateTables = false;
if ( ! isset($this->sharedFixture['conn'])) {
$this->sharedFixture['conn'] = TestUtil::getConnection();
if ( ! isset(self::$_sharedConn)) {
self::$_sharedConn = TestUtil::getConnection();
}
$this->sharedFixture['conn'] = self::$_sharedConn;
if ($this->sharedFixture['conn']->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) {
$forceCreateTables = true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment