mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 05:44:53 +00:00
Remove driver lists
This commit is contained in:
parent
b6dd8ab20d
commit
3ef1177f06
5 changed files with 0 additions and 53 deletions
|
@ -78,21 +78,6 @@ class Database {
|
||||||
return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'];
|
return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Lists the available database drivers, as an associative array with
|
|
||||||
* fully-qualified class names as keys, and human-readable descriptions as values
|
|
||||||
*/
|
|
||||||
public static function driverList(): array {
|
|
||||||
$sep = \DIRECTORY_SEPARATOR;
|
|
||||||
$path = __DIR__.$sep."Db".$sep;
|
|
||||||
$classes = [];
|
|
||||||
foreach (glob($path."*".$sep."Driver.php") as $file) {
|
|
||||||
$name = basename(dirname($file));
|
|
||||||
$class = NS_BASE."Db\\$name\\Driver";
|
|
||||||
$classes[$class] = $class::driverName();
|
|
||||||
}
|
|
||||||
return $classes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the current (actual) schema version of the database; compared against self::SCHEMA_VERSION to know when an upgrade is required */
|
/** Returns the current (actual) schema version of the database; compared against self::SCHEMA_VERSION to know when an upgrade is required */
|
||||||
public function driverSchemaVersion(): int {
|
public function driverSchemaVersion(): int {
|
||||||
return $this->db->schemaVersion();
|
return $this->db->schemaVersion();
|
||||||
|
|
|
@ -20,18 +20,6 @@ class Service {
|
||||||
/** @var \DateInterval */
|
/** @var \DateInterval */
|
||||||
protected $interval;
|
protected $interval;
|
||||||
|
|
||||||
public static function driverList(): array {
|
|
||||||
$sep = \DIRECTORY_SEPARATOR;
|
|
||||||
$path = __DIR__.$sep."Service".$sep;
|
|
||||||
$classes = [];
|
|
||||||
foreach (glob($path."*".$sep."Driver.php") as $file) {
|
|
||||||
$name = basename(dirname($file));
|
|
||||||
$class = NS_BASE."User\\$name\\Driver";
|
|
||||||
$classes[$class] = $class::driverName();
|
|
||||||
}
|
|
||||||
return $classes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$driver = Arsse::$conf->serviceDriver;
|
$driver = Arsse::$conf->serviceDriver;
|
||||||
$this->drv = new $driver();
|
$this->drv = new $driver();
|
||||||
|
|
12
lib/User.php
12
lib/User.php
|
@ -20,18 +20,6 @@ class User {
|
||||||
*/
|
*/
|
||||||
protected $u;
|
protected $u;
|
||||||
|
|
||||||
public static function driverList(): array {
|
|
||||||
$sep = \DIRECTORY_SEPARATOR;
|
|
||||||
$path = __DIR__.$sep."User".$sep;
|
|
||||||
$classes = [];
|
|
||||||
foreach (glob($path."*".$sep."Driver.php") as $file) {
|
|
||||||
$name = basename(dirname($file));
|
|
||||||
$class = NS_BASE."User\\$name\\Driver";
|
|
||||||
$classes[$class] = $class::driverName();
|
|
||||||
}
|
|
||||||
return $classes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __construct(\JKingWeb\Arsse\User\Driver $driver = null) {
|
public function __construct(\JKingWeb\Arsse\User\Driver $driver = null) {
|
||||||
$this->u = $driver ?? new Arsse::$conf->userDriver;
|
$this->u = $driver ?? new Arsse::$conf->userDriver;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,6 @@ trait SeriesMiscellany {
|
||||||
protected function tearDownSeriesMiscellany() {
|
protected function tearDownSeriesMiscellany() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testListDrivers() {
|
|
||||||
$exp = [
|
|
||||||
'JKingWeb\\Arsse\\Db\\SQLite3\\Driver' => Arsse::$lang->msg("Driver.Db.SQLite3.Name"),
|
|
||||||
];
|
|
||||||
$this->assertArraySubset($exp, Database::driverList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInitializeDatabase() {
|
public function testInitializeDatabase() {
|
||||||
static::dbRaze(static::$drv);
|
static::dbRaze(static::$drv);
|
||||||
$d = new Database(true);
|
$d = new Database(true);
|
||||||
|
|
|
@ -24,13 +24,6 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
$this->drv = \Phake::mock(Driver::class);
|
$this->drv = \Phake::mock(Driver::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testListDrivers() {
|
|
||||||
$exp = [
|
|
||||||
'JKingWeb\\Arsse\\User\\Internal\\Driver' => Arsse::$lang->msg("Driver.User.Internal.Name"),
|
|
||||||
];
|
|
||||||
$this->assertArraySubset($exp, User::driverList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testConstruct() {
|
public function testConstruct() {
|
||||||
$this->assertInstanceOf(User::class, new User($this->drv));
|
$this->assertInstanceOf(User::class, new User($this->drv));
|
||||||
$this->assertInstanceOf(User::class, new User);
|
$this->assertInstanceOf(User::class, new User);
|
||||||
|
|
Loading…
Reference in a new issue