diff --git a/tests/cases/Db/SQLite3/TestDriver.php b/tests/cases/Db/SQLite3/TestDriver.php index 4c80cba..b3eb359 100644 --- a/tests/cases/Db/SQLite3/TestDriver.php +++ b/tests/cases/Db/SQLite3/TestDriver.php @@ -26,8 +26,10 @@ class TestDriver extends \JKingWeb\Arsse\TestCase\Db\BaseDriver { } public static function tearDownAfterClass(): void { - static::$interface->close(); - static::$interface = null; + if (static::$interface) { + static::$interface->close(); + static::$interface = null; + } parent::tearDownAfterClass(); @unlink(static::$file); static::$file = null; diff --git a/tests/cases/Db/SQLite3/TestResult.php b/tests/cases/Db/SQLite3/TestResult.php index d7f8c09..5a8d0cd 100644 --- a/tests/cases/Db/SQLite3/TestResult.php +++ b/tests/cases/Db/SQLite3/TestResult.php @@ -16,8 +16,10 @@ class TestResult extends \JKingWeb\Arsse\TestCase\Db\BaseResult { protected static $createTest = "CREATE TABLE arsse_test(id integer primary key)"; public static function tearDownAfterClass(): void { - static::$interface->close(); - static::$interface = null; + if (static::$interface) { + static::$interface->close(); + static::$interface = null; + } parent::tearDownAfterClass(); } diff --git a/tests/cases/Db/SQLite3/TestStatement.php b/tests/cases/Db/SQLite3/TestStatement.php index 1af5be4..f7b970f 100644 --- a/tests/cases/Db/SQLite3/TestStatement.php +++ b/tests/cases/Db/SQLite3/TestStatement.php @@ -13,8 +13,10 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement { use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3; public static function tearDownAfterClass(): void { - static::$interface->close(); - static::$interface = null; + if (static::$interface) { + static::$interface->close(); + static::$interface = null; + } parent::tearDownAfterClass(); } diff --git a/tests/cases/Db/SQLite3/TestUpdate.php b/tests/cases/Db/SQLite3/TestUpdate.php index 94842e2..409f109 100644 --- a/tests/cases/Db/SQLite3/TestUpdate.php +++ b/tests/cases/Db/SQLite3/TestUpdate.php @@ -16,8 +16,10 @@ class TestUpdate extends \JKingWeb\Arsse\TestCase\Db\BaseUpdate { protected static $minimal2 = "pragma user_version=2"; public static function tearDownAfterClass(): void { - static::$interface->close(); - static::$interface = null; + if (static::$interface) { + static::$interface->close(); + static::$interface = null; + } parent::tearDownAfterClass(); } } diff --git a/tests/lib/DatabaseDrivers/MySQL.php b/tests/lib/DatabaseDrivers/MySQL.php index f1571a2..01501f1 100644 --- a/tests/lib/DatabaseDrivers/MySQL.php +++ b/tests/lib/DatabaseDrivers/MySQL.php @@ -18,9 +18,12 @@ trait MySQL { protected static $stringOutput = true; 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); if ($d->connect_errno) { - return; + return null; } $d->set_charset("utf8mb4"); foreach (\JKingWeb\Arsse\Db\MySQL\PDODriver::makeSetupQueries() as $q) { diff --git a/tests/lib/DatabaseDrivers/PostgreSQL.php b/tests/lib/DatabaseDrivers/PostgreSQL.php index fb0038c..edc7549 100644 --- a/tests/lib/DatabaseDrivers/PostgreSQL.php +++ b/tests/lib/DatabaseDrivers/PostgreSQL.php @@ -19,7 +19,7 @@ trait PostgreSQL { 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, ""); - 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) { pg_query($d, $q); }