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; ...@@ -4,15 +4,19 @@ namespace Doctrine\Tests;
class DbalFunctionalTestCase extends DbalTestCase class DbalFunctionalTestCase extends DbalTestCase
{ {
/* Shared connection when a TestCase is run alone (outside of it's functional suite) */
private static $_sharedConn;
protected $_conn; protected $_conn;
protected function setUp() protected function setUp()
{ {
if ( ! isset($this->_conn)) { if (isset($this->sharedFixture['conn'])) {
if ( ! isset($this->sharedFixture['conn'])) {
$this->sharedFixture['conn'] = TestUtil::getConnection();
}
$this->_conn = $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 ...@@ -14,6 +14,9 @@ class OrmFunctionalTestCase extends OrmTestCase
/* The query cache shared between all functional tests. */ /* The query cache shared between all functional tests. */
private static $_queryCacheImpl = null; 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. */ /** The EntityManager for this testcase. */
protected $_em; protected $_em;
...@@ -79,8 +82,12 @@ class OrmFunctionalTestCase extends OrmTestCase ...@@ -79,8 +82,12 @@ class OrmFunctionalTestCase extends OrmTestCase
protected function setUp() protected function setUp()
{ {
$forceCreateTables = false; $forceCreateTables = false;
if ( ! isset($this->sharedFixture['conn'])) { 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) { if ($this->sharedFixture['conn']->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) {
$forceCreateTables = true; $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