From 717e74fb2e0c528ace3a6af5515d1edfd4e604c3 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Wed, 3 May 2017 20:00:29 -0400 Subject: [PATCH] Refactored special case for testing --- lib/Database.php | 17 ++++++----------- tests/lib/Database.php | 9 +++++++++ tests/lib/Database/Setup.php | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 tests/lib/Database.php diff --git a/lib/Database.php b/lib/Database.php index 194465e7..840fef42 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -14,17 +14,12 @@ class Database { public $db; private $driver; - public function __construct(Db\Driver $db = null) { - // if we're fed a pre-prepared driver, use it' - if($db) { - $this->db = $db; - } else { - $this->driver = $driver = Data::$conf->dbDriver; - $this->db = new $driver(INSTALL); - $ver = $this->db->schemaVersion(); - if(!INSTALL && $ver < self::SCHEMA_VERSION) { - $this->db->schemaUpdate(self::SCHEMA_VERSION); - } + public function __construct() { + $this->driver = $driver = Data::$conf->dbDriver; + $this->db = new $driver(INSTALL); + $ver = $this->db->schemaVersion(); + if(!INSTALL && $ver < self::SCHEMA_VERSION) { + $this->db->schemaUpdate(self::SCHEMA_VERSION); } } diff --git a/tests/lib/Database.php b/tests/lib/Database.php new file mode 100644 index 00000000..432aa046 --- /dev/null +++ b/tests/lib/Database.php @@ -0,0 +1,9 @@ +db = $drv; + } +} \ No newline at end of file diff --git a/tests/lib/Database/Setup.php b/tests/lib/Database/Setup.php index d9ed531b..2d74860b 100644 --- a/tests/lib/Database/Setup.php +++ b/tests/lib/Database/Setup.php @@ -5,7 +5,7 @@ use JKingWeb\Arsse\User\Driver as UserDriver; use JKingWeb\Arsse\Data; use JKingWeb\Arsse\Conf; use JKingWeb\Arsse\User; -use JKingWeb\Arsse\Database; +use JKingWeb\Arsse\Test\Database; use Phake; trait Setup {