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,11 +14,7 @@ class Database {
|
||||||
public $db;
|
public $db;
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
public function __construct(Db\Driver $db = null) {
|
public function __construct() {
|
||||||
// if we're fed a pre-prepared driver, use it'
|
|
||||||
if($db) {
|
|
||||||
$this->db = $db;
|
|
||||||
} else {
|
|
||||||
$this->driver = $driver = Data::$conf->dbDriver;
|
$this->driver = $driver = Data::$conf->dbDriver;
|
||||||
$this->db = new $driver(INSTALL);
|
$this->db = new $driver(INSTALL);
|
||||||
$ver = $this->db->schemaVersion();
|
$ver = $this->db->schemaVersion();
|
||||||
|
@ -26,7 +22,6 @@ class Database {
|
||||||
$this->db->schemaUpdate(self::SCHEMA_VERSION);
|
$this->db->schemaUpdate(self::SCHEMA_VERSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static public function listDrivers(): array {
|
static public function listDrivers(): array {
|
||||||
$sep = \DIRECTORY_SEPARATOR;
|
$sep = \DIRECTORY_SEPARATOR;
|
||||||
|
|
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\Data;
|
||||||
use JKingWeb\Arsse\Conf;
|
use JKingWeb\Arsse\Conf;
|
||||||
use JKingWeb\Arsse\User;
|
use JKingWeb\Arsse\User;
|
||||||
use JKingWeb\Arsse\Database;
|
use JKingWeb\Arsse\Test\Database;
|
||||||
use Phake;
|
use Phake;
|
||||||
|
|
||||||
trait Setup {
|
trait Setup {
|
||||||
|
|
Loading…
Reference in a new issue