Browse Source

Simplify database cleanup between tests

microsub
J. King 5 years ago
parent
commit
73729a6be8
  1. 8
      tests/cases/Db/BaseDriver.php
  2. 10
      tests/cases/Db/BaseResult.php
  3. 10
      tests/cases/Db/BaseStatement.php
  4. 10
      tests/cases/Db/BaseUpdate.php
  5. 5
      tests/cases/Db/SQLite3/TestDriver.php
  6. 5
      tests/cases/Db/SQLite3/TestResult.php
  7. 1
      tests/cases/Db/SQLite3/TestStatement.php
  8. 6
      tests/cases/Db/SQLite3/TestUpdate.php

8
tests/cases/Db/BaseDriver.php

@ -49,14 +49,14 @@ abstract class BaseDriver extends \JKingWeb\Arsse\Test\AbstractTest {
public function tearDown() {
// deconstruct the driver
unset($this->drv);
if (static::$interface) {
// completely clear the database
(static::$dbInfo->razeFunction)(static::$interface);
}
self::clearData();
}
public static function tearDownAfterClass() {
if (static::$interface) {
// completely clear the database
(static::$dbInfo->razeFunction)(static::$interface);
}
static::$interface = null;
static::$dbInfo = null;
self::clearData();

10
tests/cases/Db/BaseResult.php

@ -38,15 +38,15 @@ abstract class BaseResult extends \JKingWeb\Arsse\Test\AbstractTest {
}
public function tearDown() {
if (static::$interface) {
// completely clear the database
(static::$dbInfo->razeFunction)(static::$interface);
}
self::clearData();
}
public static function tearDownAfterClass() {
static::$implementation = null;
if (static::$interface) {
// completely clear the database
(static::$dbInfo->razeFunction)(static::$interface);
}
static::$interface = null;
static::$dbInfo = null;
self::clearData();
}

10
tests/cases/Db/BaseStatement.php

@ -39,15 +39,15 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
}
public function tearDown() {
if (static::$interface) {
// completely clear the database
(static::$dbInfo->razeFunction)(static::$interface);
}
self::clearData();
}
public static function tearDownAfterClass() {
static::$implementation = null;
if (static::$interface) {
// completely clear the database
(static::$dbInfo->razeFunction)(static::$interface);
}
static::$interface = null;
static::$dbInfo = null;
self::clearData();
}

10
tests/cases/Db/BaseUpdate.php

@ -48,16 +48,16 @@ class BaseUpdate extends \JKingWeb\Arsse\Test\AbstractTest {
public function tearDown() {
// deconstruct the driver
unset($this->drv);
if (static::$interface) {
// completely clear the database
(static::$dbInfo->razeFunction)(static::$interface);
}
unset($this->path, $this->base, $this->vfs);
self::clearData();
}
public static function tearDownAfterClass() {
static::$implementation = null;
if (static::$interface) {
// completely clear the database
(static::$dbInfo->razeFunction)(static::$interface);
}
static::$interface = null;
static::$dbInfo = null;
self::clearData();
}

5
tests/cases/Db/SQLite3/TestDriver.php

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

5
tests/cases/Db/SQLite3/TestResult.php

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

1
tests/cases/Db/SQLite3/TestStatement.php

@ -14,6 +14,7 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
public static function tearDownAfterClass() {
static::$interface->close();
static::$interface = null;
parent::tearDownAfterClass();
}

6
tests/cases/Db/SQLite3/TestUpdate.php

@ -13,4 +13,10 @@ class TestUpdate extends \JKingWeb\Arsse\TestCase\Db\BaseUpdate {
protected static $implementation = "SQLite 3";
protected static $minimal1 = "create table arsse_meta(key text primary key not null, value text); pragma user_version=1";
protected static $minimal2 = "pragma user_version=2";
public static function tearDownAfterClass() {
static::$interface->close();
static::$interface = null;
parent::tearDownAfterClass();
}
}

Loading…
Cancel
Save