Browse Source

Fix tests in absence of database extensions

rpm
J. King 4 years ago
parent
commit
3ac010d5b6
  1. 6
      tests/cases/Db/SQLite3/TestDriver.php
  2. 6
      tests/cases/Db/SQLite3/TestResult.php
  3. 6
      tests/cases/Db/SQLite3/TestStatement.php
  4. 6
      tests/cases/Db/SQLite3/TestUpdate.php
  5. 5
      tests/lib/DatabaseDrivers/MySQL.php
  6. 2
      tests/lib/DatabaseDrivers/PostgreSQL.php

6
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;

6
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();
}

6
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();
}

6
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();
}
}

5
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) {

2
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);
}

Loading…
Cancel
Save