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;
|
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'
|
$this->driver = $driver = Data::$conf->dbDriver;
|
||||||
if($db) {
|
$this->db = new $driver(INSTALL);
|
||||||
$this->db = $db;
|
$ver = $this->db->schemaVersion();
|
||||||
} else {
|
if(!INSTALL && $ver < self::SCHEMA_VERSION) {
|
||||||
$this->driver = $driver = Data::$conf->dbDriver;
|
$this->db->schemaUpdate(self::SCHEMA_VERSION);
|
||||||
$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\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