1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00

Set up test better

This commit is contained in:
J. King 2019-09-12 11:14:30 -04:00
parent 3da884dfbc
commit a143c86136

View file

@ -10,16 +10,20 @@ use JKingWeb\Arsse\Database;
/** @covers \JKingWeb\Arsse\Database */ /** @covers \JKingWeb\Arsse\Database */
class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
static $db = null; protected $db = null;
public static function setUpBeforeClass() { public function setUp() {
self::clearData(); self::clearData();
self::setConf(); self::setConf();
self::$db = \Phake::makeVisible(\Phake::partialMock(Database::class)); try {
$this->db = \Phake::makeVisible(\Phake::partialMock(Database::class));
} catch (\JKingWeb\Arsse\Db\Exception $e) {
$this->markTestSkipped("SQLite 3 database driver not available");
}
} }
public static function tearDownAfterClass() { public function tearDown() {
self::$db = null; $this->db = null;
self::clearData(); self::clearData();
} }
@ -27,7 +31,7 @@ class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
public function testGenerateInClause(string $clause, array $values, array $inV, string $inT) { public function testGenerateInClause(string $clause, array $values, array $inV, string $inT) {
$types = array_fill(0, sizeof($values), $inT); $types = array_fill(0, sizeof($values), $inT);
$exp = [$clause, $types, $values]; $exp = [$clause, $types, $values];
$this->assertSame($exp, self::$db->generateIn($inV, $inT)); $this->assertSame($exp, $this->db->generateIn($inV, $inT));
} }
public function provideInClauses() { public function provideInClauses() {
@ -62,7 +66,7 @@ class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
// this is not an exhaustive test; integration tests already cover the ins and outs of the functionality // this is not an exhaustive test; integration tests already cover the ins and outs of the functionality
$types = array_fill(0, sizeof($values), "str"); $types = array_fill(0, sizeof($values), "str");
$exp = [$clause, $types, $values]; $exp = [$clause, $types, $values];
$this->assertSame($exp, self::$db->generateSearch($inV, $inC, $inAny)); $this->assertSame($exp, $this->db->generateSearch($inV, $inC, $inAny));
} }
public function provideSearchClauses() { public function provideSearchClauses() {