1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2025-01-03 14:32:40 +00:00

Fix tests in absence of database extensions

This commit is contained in:
J. King 2020-10-30 12:16:03 -04:00
parent b58a326461
commit 3ac010d5b6
6 changed files with 21 additions and 10 deletions

View file

@ -26,8 +26,10 @@ class TestDriver extends \JKingWeb\Arsse\TestCase\Db\BaseDriver {
} }
public static function tearDownAfterClass(): void { public static function tearDownAfterClass(): void {
static::$interface->close(); if (static::$interface) {
static::$interface = null; static::$interface->close();
static::$interface = null;
}
parent::tearDownAfterClass(); parent::tearDownAfterClass();
@unlink(static::$file); @unlink(static::$file);
static::$file = null; static::$file = null;

View file

@ -16,8 +16,10 @@ class TestResult extends \JKingWeb\Arsse\TestCase\Db\BaseResult {
protected static $createTest = "CREATE TABLE arsse_test(id integer primary key)"; protected static $createTest = "CREATE TABLE arsse_test(id integer primary key)";
public static function tearDownAfterClass(): void { public static function tearDownAfterClass(): void {
static::$interface->close(); if (static::$interface) {
static::$interface = null; static::$interface->close();
static::$interface = null;
}
parent::tearDownAfterClass(); parent::tearDownAfterClass();
} }

View file

@ -13,8 +13,10 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3; use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3;
public static function tearDownAfterClass(): void { public static function tearDownAfterClass(): void {
static::$interface->close(); if (static::$interface) {
static::$interface = null; static::$interface->close();
static::$interface = null;
}
parent::tearDownAfterClass(); parent::tearDownAfterClass();
} }

View file

@ -16,8 +16,10 @@ class TestUpdate extends \JKingWeb\Arsse\TestCase\Db\BaseUpdate {
protected static $minimal2 = "pragma user_version=2"; protected static $minimal2 = "pragma user_version=2";
public static function tearDownAfterClass(): void { public static function tearDownAfterClass(): void {
static::$interface->close(); if (static::$interface) {
static::$interface = null; static::$interface->close();
static::$interface = null;
}
parent::tearDownAfterClass(); parent::tearDownAfterClass();
} }
} }

View file

@ -18,9 +18,12 @@ trait MySQL {
protected static $stringOutput = true; protected static $stringOutput = true;
public static function dbInterface() { public static function dbInterface() {
if (!class_exists("mysqli")) {
return null;
}
$d = @new \mysqli(Arsse::$conf->dbMySQLHost, Arsse::$conf->dbMySQLUser, Arsse::$conf->dbMySQLPass, Arsse::$conf->dbMySQLDb, Arsse::$conf->dbMySQLPort); $d = @new \mysqli(Arsse::$conf->dbMySQLHost, Arsse::$conf->dbMySQLUser, Arsse::$conf->dbMySQLPass, Arsse::$conf->dbMySQLDb, Arsse::$conf->dbMySQLPort);
if ($d->connect_errno) { if ($d->connect_errno) {
return; return null;
} }
$d->set_charset("utf8mb4"); $d->set_charset("utf8mb4");
foreach (\JKingWeb\Arsse\Db\MySQL\PDODriver::makeSetupQueries() as $q) { foreach (\JKingWeb\Arsse\Db\MySQL\PDODriver::makeSetupQueries() as $q) {

View file

@ -19,7 +19,7 @@ trait PostgreSQL {
public static function dbInterface() { public static function dbInterface() {
$connString = \JKingWeb\Arsse\Db\PostgreSQL\Driver::makeConnectionString(false, Arsse::$conf->dbPostgreSQLUser, Arsse::$conf->dbPostgreSQLPass, Arsse::$conf->dbPostgreSQLDb, Arsse::$conf->dbPostgreSQLHost, Arsse::$conf->dbPostgreSQLPort, ""); $connString = \JKingWeb\Arsse\Db\PostgreSQL\Driver::makeConnectionString(false, Arsse::$conf->dbPostgreSQLUser, Arsse::$conf->dbPostgreSQLPass, Arsse::$conf->dbPostgreSQLDb, Arsse::$conf->dbPostgreSQLHost, Arsse::$conf->dbPostgreSQLPort, "");
if ($d = @pg_connect($connString, \PGSQL_CONNECT_FORCE_NEW)) { if (function_exists("pg_connect") && $d = @pg_connect($connString, \PGSQL_CONNECT_FORCE_NEW)) {
foreach (\JKingWeb\Arsse\Db\PostgreSQL\Driver::makeSetupQueries(Arsse::$conf->dbPostgreSQLSchema) as $q) { foreach (\JKingWeb\Arsse\Db\PostgreSQL\Driver::makeSetupQueries(Arsse::$conf->dbPostgreSQLSchema) as $q) {
pg_query($d, $q); pg_query($d, $q);
} }