Commit 0300683b by Carsten Brandt

improved db test, avoid error by accessing db directlry

always use getConnection()
parent f177f170
...@@ -11,7 +11,7 @@ abstract class DatabaseTestCase extends TestCase ...@@ -11,7 +11,7 @@ abstract class DatabaseTestCase extends TestCase
/** /**
* @var Connection * @var Connection
*/ */
protected $db; private $_db;
protected function setUp() protected function setUp()
{ {
...@@ -28,8 +28,8 @@ abstract class DatabaseTestCase extends TestCase ...@@ -28,8 +28,8 @@ abstract class DatabaseTestCase extends TestCase
protected function tearDown() protected function tearDown()
{ {
if ($this->db) { if ($this->_db) {
$this->db->close(); $this->_db->close();
} }
$this->destroyApplication(); $this->destroyApplication();
} }
...@@ -41,8 +41,8 @@ abstract class DatabaseTestCase extends TestCase ...@@ -41,8 +41,8 @@ abstract class DatabaseTestCase extends TestCase
*/ */
public function getConnection($reset = true, $open = true) public function getConnection($reset = true, $open = true)
{ {
if (!$reset && $this->db) { if (!$reset && $this->_db) {
return $this->db; return $this->_db;
} }
$config = $this->database; $config = $this->database;
if (isset($config['fixture'])) { if (isset($config['fixture'])) {
...@@ -52,11 +52,11 @@ abstract class DatabaseTestCase extends TestCase ...@@ -52,11 +52,11 @@ abstract class DatabaseTestCase extends TestCase
$fixture = null; $fixture = null;
} }
try { try {
$this->db = $this->prepareDatabase($config, $fixture, $open); $this->_db = $this->prepareDatabase($config, $fixture, $open);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->markTestSkipped("Something wrong when preparing database: " . $e->getMessage()); $this->markTestSkipped("Something wrong when preparing database: " . $e->getMessage());
} }
return $this->db; return $this->_db;
} }
public function prepareDatabase($config, $fixture, $open = true) public function prepareDatabase($config, $fixture, $open = 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