mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Test cleanup
This commit is contained in:
parent
edfae438fa
commit
976672de5b
7 changed files with 24 additions and 25 deletions
|
@ -107,7 +107,7 @@ class TestCreation extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
chmod($path."Awal/arsse.db-wal", 0111);
|
chmod($path."Awal/arsse.db-wal", 0111);
|
||||||
chmod($path."Ashm/arsse.db-shm", 0111);
|
chmod($path."Ashm/arsse.db-shm", 0111);
|
||||||
// set up configuration
|
// set up configuration
|
||||||
$this->setConf(['dbSQLite3File' => ":memory:"]);
|
$this->setConf();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
|
|
@ -25,16 +25,13 @@ class TestUpdate extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
const MINIMAL1 = "create table arsse_meta(key text primary key not null, value text); pragma user_version=1";
|
const MINIMAL1 = "create table arsse_meta(key text primary key not null, value text); pragma user_version=1";
|
||||||
const MINIMAL2 = "pragma user_version=2";
|
const MINIMAL2 = "pragma user_version=2";
|
||||||
|
|
||||||
public function setUp(Conf $conf = null) {
|
public function setUp(array $conf = []) {
|
||||||
if (!Driver::requirementsMet()) {
|
if (!Driver::requirementsMet()) {
|
||||||
$this->markTestSkipped("SQLite extension not loaded");
|
$this->markTestSkipped("SQLite extension not loaded");
|
||||||
}
|
}
|
||||||
$this->clearData();
|
$this->clearData();
|
||||||
$this->vfs = vfsStream::setup("schemata", null, ['SQLite3' => []]);
|
$this->vfs = vfsStream::setup("schemata", null, ['SQLite3' => []]);
|
||||||
$conf = $conf ?? new Conf;
|
$this->setConf($conf);
|
||||||
$conf->dbDriver = Driver::class;
|
|
||||||
$conf->dbSQLite3File = ":memory:";
|
|
||||||
Arsse::$conf = $conf;
|
|
||||||
$this->base = $this->vfs->url();
|
$this->base = $this->vfs->url();
|
||||||
$this->path = $this->base."/SQLite3/";
|
$this->path = $this->base."/SQLite3/";
|
||||||
$this->drv = new Driver();
|
$this->drv = new Driver();
|
||||||
|
@ -109,9 +106,7 @@ class TestUpdate extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
|
|
||||||
public function testDeclineManualUpdate() {
|
public function testDeclineManualUpdate() {
|
||||||
// turn auto-updating off
|
// turn auto-updating off
|
||||||
$conf = new Conf;
|
$this->setUp(['dbAutoUpdate' => false]);
|
||||||
$conf->dbAutoUpdate = false;
|
|
||||||
$this->setUp($conf);
|
|
||||||
$this->assertException("updateManual", "Db");
|
$this->assertException("updateManual", "Db");
|
||||||
$this->drv->schemaUpdate(Database::SCHEMA_VERSION);
|
$this->drv->schemaUpdate(Database::SCHEMA_VERSION);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ class TestCreation extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
chmod($path."Awal/arsse.db-wal", 0111);
|
chmod($path."Awal/arsse.db-wal", 0111);
|
||||||
chmod($path."Ashm/arsse.db-shm", 0111);
|
chmod($path."Ashm/arsse.db-shm", 0111);
|
||||||
// set up configuration
|
// set up configuration
|
||||||
$this->setConf(['dbSQLite3File' => ":memory:"]);
|
$this->setConf();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
|
|
@ -25,18 +25,14 @@ class TestUpdate extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
const MINIMAL1 = "create table arsse_meta(key text primary key not null, value text); pragma user_version=1";
|
const MINIMAL1 = "create table arsse_meta(key text primary key not null, value text); pragma user_version=1";
|
||||||
const MINIMAL2 = "pragma user_version=2";
|
const MINIMAL2 = "pragma user_version=2";
|
||||||
|
|
||||||
public function setUp(Conf $conf = null) {
|
public function setUp(array $conf = []) {
|
||||||
if (!PDODriver::requirementsMet()) {
|
if (!PDODriver::requirementsMet()) {
|
||||||
$this->markTestSkipped("PDO-SQLite extension not loaded");
|
$this->markTestSkipped("PDO-SQLite extension not loaded");
|
||||||
}
|
}
|
||||||
$this->clearData();
|
$this->clearData();
|
||||||
$this->vfs = vfsStream::setup("schemata", null, ['SQLite3' => []]);
|
$this->vfs = vfsStream::setup("schemata", null, ['SQLite3' => []]);
|
||||||
if (!$conf) {
|
$conf['dbDriver'] = PDODriver::class;
|
||||||
$conf = new Conf();
|
$this->setConf($conf);
|
||||||
}
|
|
||||||
$conf->dbDriver = PDODriver::class;
|
|
||||||
$conf->dbSQLite3File = ":memory:";
|
|
||||||
Arsse::$conf = $conf;
|
|
||||||
$this->base = $this->vfs->url();
|
$this->base = $this->vfs->url();
|
||||||
$this->path = $this->base."/SQLite3/";
|
$this->path = $this->base."/SQLite3/";
|
||||||
$this->drv = new PDODriver();
|
$this->drv = new PDODriver();
|
||||||
|
@ -111,9 +107,7 @@ class TestUpdate extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
|
|
||||||
public function testDeclineManualUpdate() {
|
public function testDeclineManualUpdate() {
|
||||||
// turn auto-updating off
|
// turn auto-updating off
|
||||||
$conf = new Conf();
|
$this->setUp(['dbAutoUpdate' => false]);
|
||||||
$conf->dbAutoUpdate = false;
|
|
||||||
$this->setUp($conf);
|
|
||||||
$this->assertException("updateManual", "Db");
|
$this->assertException("updateManual", "Db");
|
||||||
$this->drv->schemaUpdate(Database::SCHEMA_VERSION);
|
$this->drv->schemaUpdate(Database::SCHEMA_VERSION);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
namespace JKingWeb\Arsse\TestCase\Db;
|
namespace JKingWeb\Arsse\TestCase\Db;
|
||||||
|
|
||||||
|
use JKingWeb\Arsse\Arsse;
|
||||||
use JKingWeb\Arsse\Db\Result;
|
use JKingWeb\Arsse\Db\Result;
|
||||||
use JKingWeb\Arsse\Db\PDOResult;
|
use JKingWeb\Arsse\Db\PDOResult;
|
||||||
use JKingWeb\Arsse\Db\SQLite3\PDODriver;
|
use JKingWeb\Arsse\Db\SQLite3\PDODriver;
|
||||||
|
@ -16,16 +17,17 @@ use JKingWeb\Arsse\Db\SQLite3\PDODriver;
|
||||||
*/
|
*/
|
||||||
class TestResult extends \JKingWeb\Arsse\Test\AbstractTest {
|
class TestResult extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
public function provideDrivers() {
|
public function provideDrivers() {
|
||||||
|
$this->setConf();
|
||||||
$drvSqlite3 = (function() {
|
$drvSqlite3 = (function() {
|
||||||
if (\JKingWeb\Arsse\Db\SQLite3\Driver::requirementsMet()) {
|
if (\JKingWeb\Arsse\Db\SQLite3\Driver::requirementsMet()) {
|
||||||
$d = new \SQLite3(":memory:");
|
$d = new \SQLite3(Arsse::$conf->dbSQLite3File);
|
||||||
$d->enableExceptions(true);
|
$d->enableExceptions(true);
|
||||||
return $d;
|
return $d;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
$drvPdo = (function() {
|
$drvPdo = (function() {
|
||||||
if (\JKingWeb\Arsse\Db\SQLite3\PDODriver::requirementsMet()) {
|
if (\JKingWeb\Arsse\Db\SQLite3\PDODriver::requirementsMet()) {
|
||||||
return new \PDO("sqlite::memory:", "", "", [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]);
|
return new \PDO("sqlite:".Arsse::$conf->dbSQLite3File, "", "", [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
namespace JKingWeb\Arsse\TestCase\Db;
|
namespace JKingWeb\Arsse\TestCase\Db;
|
||||||
|
|
||||||
|
use JKingWeb\Arsse\Arsse;
|
||||||
use JKingWeb\Arsse\Db\Statement;
|
use JKingWeb\Arsse\Db\Statement;
|
||||||
use JKingWeb\Arsse\Db\PDOStatement;
|
use JKingWeb\Arsse\Db\PDOStatement;
|
||||||
|
|
||||||
|
@ -16,16 +17,17 @@ use JKingWeb\Arsse\Db\PDOStatement;
|
||||||
* @covers \JKingWeb\Arsse\Db\PDOError */
|
* @covers \JKingWeb\Arsse\Db\PDOError */
|
||||||
class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest {
|
class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
public function provideDrivers() {
|
public function provideDrivers() {
|
||||||
|
$this->setConf();
|
||||||
$drvSqlite3 = (function() {
|
$drvSqlite3 = (function() {
|
||||||
if (\JKingWeb\Arsse\Db\SQLite3\Driver::requirementsMet()) {
|
if (\JKingWeb\Arsse\Db\SQLite3\Driver::requirementsMet()) {
|
||||||
$d = new \SQLite3(":memory:");
|
$d = new \SQLite3(Arsse::$conf->dbSQLite3File);
|
||||||
$d->enableExceptions(true);
|
$d->enableExceptions(true);
|
||||||
return $d;
|
return $d;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
$drvPdo = (function() {
|
$drvPdo = (function() {
|
||||||
if (\JKingWeb\Arsse\Db\SQLite3\PDODriver::requirementsMet()) {
|
if (\JKingWeb\Arsse\Db\SQLite3\PDODriver::requirementsMet()) {
|
||||||
return new \PDO("sqlite::memory:", "", "", [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]);
|
return new \PDO("sqlite:".Arsse::$conf->dbSQLite3File, "", "", [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -41,7 +41,13 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setConf(array $conf = []) {
|
public function setConf(array $conf = []) {
|
||||||
Arsse::$conf = (new Conf)->import($conf);
|
$defaults = [
|
||||||
|
'dbSQLite3File' => ":memory:",
|
||||||
|
'dbPostgreSQLUser' => "arsse_test",
|
||||||
|
'dbPostgreSQLPass' => "arsse_test",
|
||||||
|
'dbPostgreSQLDb' => "arsse_test",
|
||||||
|
];
|
||||||
|
Arsse::$conf = (new Conf)->import($defaults)->import($conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assertException(string $msg = "", string $prefix = "", string $type = "Exception") {
|
public function assertException(string $msg = "", string $prefix = "", string $type = "Exception") {
|
||||||
|
|
Loading…
Reference in a new issue