mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Refactored special case for testing
This commit is contained in:
parent
8376cc9cb9
commit
717e74fb2e
3 changed files with 16 additions and 12 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
9
tests/lib/Database.php
Normal file
9
tests/lib/Database.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace JKingWeb\Arsse\Test;
|
||||
|
||||
class Database extends \JKingWeb\Arsse\Database {
|
||||
public function __construct(\JKingWeb\Arsse\Db\Driver $drv) {
|
||||
$this->db = $drv;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue