2017-07-23 03:08:08 +00:00
|
|
|
<?php
|
2017-11-17 01:23:18 +00:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2017-07-23 03:08:08 +00:00
|
|
|
declare(strict_types=1);
|
2018-11-23 15:01:17 +00:00
|
|
|
namespace JKingWeb\Arsse\TestCase\Database;
|
2017-08-29 14:50:31 +00:00
|
|
|
|
2017-07-23 03:08:08 +00:00
|
|
|
use JKingWeb\Arsse\Arsse;
|
|
|
|
use JKingWeb\Arsse\Database;
|
|
|
|
|
|
|
|
trait SeriesMiscellany {
|
2018-11-25 05:03:56 +00:00
|
|
|
protected function setUpSeriesMiscellany() {
|
|
|
|
static::setConf([
|
|
|
|
'dbDriver' => static::$dbInfo->driverClass,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function tearDownSeriesMiscellany() {
|
|
|
|
}
|
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function testListDrivers() {
|
2017-07-23 03:08:08 +00:00
|
|
|
$exp = [
|
|
|
|
'JKingWeb\\Arsse\\Db\\SQLite3\\Driver' => Arsse::$lang->msg("Driver.Db.SQLite3.Name"),
|
|
|
|
];
|
|
|
|
$this->assertArraySubset($exp, Database::driverList());
|
|
|
|
}
|
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function testInitializeDatabase() {
|
2018-12-05 17:54:19 +00:00
|
|
|
(static::$dbInfo->razeFunction)(static::$drv);
|
|
|
|
$d = new Database(true);
|
|
|
|
$this->assertSame(Database::SCHEMA_VERSION, $d->driverSchemaVersion());
|
2017-07-23 03:08:08 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function testManuallyInitializeDatabase() {
|
2018-11-28 17:12:49 +00:00
|
|
|
(static::$dbInfo->razeFunction)(static::$drv);
|
2017-07-23 03:08:08 +00:00
|
|
|
$d = new Database(false);
|
|
|
|
$this->assertSame(0, $d->driverSchemaVersion());
|
|
|
|
$this->assertTrue($d->driverSchemaUpdate());
|
|
|
|
$this->assertSame(Database::SCHEMA_VERSION, $d->driverSchemaVersion());
|
|
|
|
$this->assertFalse($d->driverSchemaUpdate());
|
|
|
|
}
|
2017-11-29 23:14:59 +00:00
|
|
|
|
|
|
|
public function testCheckCharacterSetAcceptability() {
|
2018-11-28 17:12:49 +00:00
|
|
|
$this->assertInternalType("bool", Arsse::$db->driverCharsetAcceptable());
|
2017-11-29 23:14:59 +00:00
|
|
|
}
|
2017-08-29 14:50:31 +00:00
|
|
|
}
|