diff --git a/tests/cases/Database/Base.php b/tests/cases/Database/AbstractTest.php similarity index 98% rename from tests/cases/Database/Base.php rename to tests/cases/Database/AbstractTest.php index f9a92f43..1bccfde2 100644 --- a/tests/cases/Database/Base.php +++ b/tests/cases/Database/AbstractTest.php @@ -10,7 +10,7 @@ use JKingWeb\Arsse\Test\Database; use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\User; -abstract class Base extends \JKingWeb\Arsse\Test\AbstractTest { +abstract class AbstractTest extends \JKingWeb\Arsse\Test\AbstractTest { use SeriesMiscellany; use SeriesMeta; use SeriesUser; diff --git a/tests/cases/Database/TestDatabase.php b/tests/cases/Database/TestDatabase.php new file mode 100644 index 00000000..bd07e469 --- /dev/null +++ b/tests/cases/Database/TestDatabase.php @@ -0,0 +1,58 @@ +assertSame($exp, self::$db->generateIn($inV, $inT)); + } + + public function provideInClauses() { + $l = Database::LIMIT_SET_SIZE + 1; + $strings = array_fill(0, $l, ""); + $ints = range(1, $l); + $longString = str_repeat("0", Database::LIMIT_SET_STRING_LENGTH + 1); + $params = implode(",", array_fill(0, $l, "?")); + $intList = implode(",", $ints); + $stringList = implode(",", array_fill(0, $l, "''")); + return [ + ["null", [], [], "str"], + ["?", [1], [1], "int"], + ["?", ["1"], ["1"], "int"], + ["?,?", [null, null], [null, null], "str"], + ["null", [], array_fill(0, $l, null), "str"], + ["$intList", [], $ints, "int"], + ["$intList,".($l+1), [], array_merge($ints, [$l+1]), "int"], + ["$intList,0", [], array_merge($ints, ["OOK"]), "int"], + ["$intList", [], array_merge($ints, [null]), "int"], + ["$stringList,''", [], array_merge($strings, [""]), "str"], + ["$stringList", [], array_merge($strings, [null]), "str"], + ["$stringList,?", [$longString], array_merge($strings, [$longString]), "str"], + ["$stringList,'A''s'", [], array_merge($strings, ["A's"]), "str"], + ["$params", $ints, $ints, "bool"], + ]; + } +} diff --git a/tests/cases/Db/MySQL/TestDatabase.php b/tests/cases/Db/MySQL/TestDatabase.php index eaf19bb8..4364170d 100644 --- a/tests/cases/Db/MySQL/TestDatabase.php +++ b/tests/cases/Db/MySQL/TestDatabase.php @@ -12,7 +12,7 @@ namespace JKingWeb\Arsse\TestCase\Db\MySQL; * @covers \JKingWeb\Arsse\Database * @covers \JKingWeb\Arsse\Misc\Query */ -class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\Base { +class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { use \JKingWeb\Arsse\Test\DatabaseDrivers\MySQL; protected function nextID(string $table): int { diff --git a/tests/cases/Db/MySQLPDO/TestDatabase.php b/tests/cases/Db/MySQLPDO/TestDatabase.php index 1b125662..6a7550ea 100644 --- a/tests/cases/Db/MySQLPDO/TestDatabase.php +++ b/tests/cases/Db/MySQLPDO/TestDatabase.php @@ -13,7 +13,7 @@ namespace JKingWeb\Arsse\TestCase\Db\MySQLPDO; * @covers \JKingWeb\Arsse\Database * @covers \JKingWeb\Arsse\Misc\Query */ -class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\Base { +class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { use \JKingWeb\Arsse\Test\DatabaseDrivers\MySQLPDO; protected function nextID(string $table): int { diff --git a/tests/cases/Db/PostgreSQL/TestDatabase.php b/tests/cases/Db/PostgreSQL/TestDatabase.php index f2277afc..9fda4d97 100644 --- a/tests/cases/Db/PostgreSQL/TestDatabase.php +++ b/tests/cases/Db/PostgreSQL/TestDatabase.php @@ -12,7 +12,7 @@ namespace JKingWeb\Arsse\TestCase\Db\PostgreSQL; * @covers \JKingWeb\Arsse\Database * @covers \JKingWeb\Arsse\Misc\Query */ -class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\Base { +class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { use \JKingWeb\Arsse\Test\DatabaseDrivers\PostgreSQL; protected function nextID(string $table): int { diff --git a/tests/cases/Db/PostgreSQLPDO/TestDatabase.php b/tests/cases/Db/PostgreSQLPDO/TestDatabase.php index 810c13c7..6f8ef2a1 100644 --- a/tests/cases/Db/PostgreSQLPDO/TestDatabase.php +++ b/tests/cases/Db/PostgreSQLPDO/TestDatabase.php @@ -13,7 +13,7 @@ namespace JKingWeb\Arsse\TestCase\Db\PostgreSQLPDO; * @covers \JKingWeb\Arsse\Database * @covers \JKingWeb\Arsse\Misc\Query */ -class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\Base { +class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { use \JKingWeb\Arsse\Test\DatabaseDrivers\PostgreSQLPDO; protected function nextID(string $table): int { diff --git a/tests/cases/Db/SQLite3/TestDatabase.php b/tests/cases/Db/SQLite3/TestDatabase.php index 3fb11399..eab0970e 100644 --- a/tests/cases/Db/SQLite3/TestDatabase.php +++ b/tests/cases/Db/SQLite3/TestDatabase.php @@ -11,7 +11,7 @@ namespace JKingWeb\Arsse\TestCase\Db\SQLite3; * @covers \JKingWeb\Arsse\Database * @covers \JKingWeb\Arsse\Misc\Query */ -class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\Base { +class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3; protected function nextID(string $table): int { diff --git a/tests/cases/Db/SQLite3PDO/TestDatabase.php b/tests/cases/Db/SQLite3PDO/TestDatabase.php index 504775e7..079bcc14 100644 --- a/tests/cases/Db/SQLite3PDO/TestDatabase.php +++ b/tests/cases/Db/SQLite3PDO/TestDatabase.php @@ -10,7 +10,7 @@ namespace JKingWeb\Arsse\TestCase\Db\SQLite3PDO; * @covers \JKingWeb\Arsse\Database * @covers \JKingWeb\Arsse\Misc\Query */ -class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\Base { +class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3PDO; protected function nextID(string $table): int { diff --git a/tests/phpunit.dist.xml b/tests/phpunit.dist.xml index cae3734f..5489f948 100644 --- a/tests/phpunit.dist.xml +++ b/tests/phpunit.dist.xml @@ -98,6 +98,7 @@ cases/Db/MySQLPDO/TestUpdate.php + cases/Database/TestDatabase.php cases/Db/SQLite3/TestDatabase.php cases/Db/SQLite3PDO/TestDatabase.php cases/Db/PostgreSQL/TestDatabase.php