From 095fe10aecd145a450816fac8f84dc0c63ec107c Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 22 Dec 2017 11:41:54 -0500 Subject: [PATCH] Reorganize PDO tests into namespaces --- .php_cs.dist | 1 + RoboFile.php | 59 ++++++++------ robo | 6 +- robo.bat | 6 +- tests/cases/Conf/TestConf.php | 5 +- .../cases/Db/SQLite3/Database/TestArticle.php | 14 ++++ .../cases/Db/SQLite3/Database/TestCleanup.php | 14 ++++ .../Database/TestDatabaseArticleSQLite3.php | 14 ---- .../Database/TestDatabaseCleanupSQLite3.php | 14 ---- .../Database/TestDatabaseFeedSQLite3.php | 14 ---- .../Database/TestDatabaseFolderSQLite3.php | 14 ---- .../Database/TestDatabaseLabelSQLite3.php | 10 --- .../Database/TestDatabaseMetaSQLite3.php | 14 ---- .../TestDatabaseMiscellanySQLite3.php | 14 ---- .../Database/TestDatabaseSessionSQLite3.php | 10 --- .../TestDatabaseSubscriptionSQLite3.php | 14 ---- .../Database/TestDatabaseUserSQLite3.php | 14 ---- tests/cases/Db/SQLite3/Database/TestFeed.php | 14 ++++ .../cases/Db/SQLite3/Database/TestFolder.php | 14 ++++ tests/cases/Db/SQLite3/Database/TestLabel.php | 10 +++ tests/cases/Db/SQLite3/Database/TestMeta.php | 14 ++++ .../Db/SQLite3/Database/TestMiscellany.php | 14 ++++ .../cases/Db/SQLite3/Database/TestSession.php | 10 +++ .../Db/SQLite3/Database/TestSubscription.php | 14 ++++ tests/cases/Db/SQLite3/Database/TestUser.php | 14 ++++ ...erCreationSQLite3.php => TestCreation.php} | 5 +- ...TestDbDriverSQLite3.php => TestDriver.php} | 19 +++-- ...TestDbResultSQLite3.php => TestResult.php} | 22 +++--- ...StatementSQLite3.php => TestStatement.php} | 10 +-- ...TestDbUpdateSQLite3.php => TestUpdate.php} | 13 ++- tests/cases/Db/TestResultAggregate.php | 19 ++--- tests/cases/Db/TestResultEmpty.php | 16 ++-- tests/cases/Db/TestTransaction.php | 9 ++- tests/cases/Exception/TestException.php | 14 ++-- tests/cases/Feed/TestFeed.php | 15 ++-- ...{TestFeedFetching.php => TestFetching.php} | 11 ++- .../Lang/{TestLang.php => TestBasic.php} | 14 ++-- .../{TestLangErrors.php => TestErrors.php} | 9 ++- .../{testLangComplex.php => testComplex.php} | 11 +-- tests/cases/Misc/TestContext.php | 4 +- tests/cases/Misc/TestValueInfo.php | 12 +-- .../{TestNCNV1_2.php => TestV1_2.php} | 18 +++-- ...NVersionDiscovery.php => TestVersions.php} | 13 +-- .../{TestTinyTinyAPI.php => TestAPI.php} | 11 ++- .../{TestTinyTinyIcon.php => TestIcon.php} | 11 ++- tests/cases/Service/TestService.php | 8 +- tests/cases/User/TestAuthorization.php | 79 ++++++++++--------- ...rMockExternal.php => TestMockExternal.php} | 8 +- ...rMockInternal.php => TestMockInternal.php} | 10 ++- ...UserInternalDriver.php => Testnternal.php} | 8 +- tests/lib/Database/Setup.php | 4 +- tests/phpunit.xml | 52 ++++++------ 52 files changed, 425 insertions(+), 341 deletions(-) create mode 100644 tests/cases/Db/SQLite3/Database/TestArticle.php create mode 100644 tests/cases/Db/SQLite3/Database/TestCleanup.php delete mode 100644 tests/cases/Db/SQLite3/Database/TestDatabaseArticleSQLite3.php delete mode 100644 tests/cases/Db/SQLite3/Database/TestDatabaseCleanupSQLite3.php delete mode 100644 tests/cases/Db/SQLite3/Database/TestDatabaseFeedSQLite3.php delete mode 100644 tests/cases/Db/SQLite3/Database/TestDatabaseFolderSQLite3.php delete mode 100644 tests/cases/Db/SQLite3/Database/TestDatabaseLabelSQLite3.php delete mode 100644 tests/cases/Db/SQLite3/Database/TestDatabaseMetaSQLite3.php delete mode 100644 tests/cases/Db/SQLite3/Database/TestDatabaseMiscellanySQLite3.php delete mode 100644 tests/cases/Db/SQLite3/Database/TestDatabaseSessionSQLite3.php delete mode 100644 tests/cases/Db/SQLite3/Database/TestDatabaseSubscriptionSQLite3.php delete mode 100644 tests/cases/Db/SQLite3/Database/TestDatabaseUserSQLite3.php create mode 100644 tests/cases/Db/SQLite3/Database/TestFeed.php create mode 100644 tests/cases/Db/SQLite3/Database/TestFolder.php create mode 100644 tests/cases/Db/SQLite3/Database/TestLabel.php create mode 100644 tests/cases/Db/SQLite3/Database/TestMeta.php create mode 100644 tests/cases/Db/SQLite3/Database/TestMiscellany.php create mode 100644 tests/cases/Db/SQLite3/Database/TestSession.php create mode 100644 tests/cases/Db/SQLite3/Database/TestSubscription.php create mode 100644 tests/cases/Db/SQLite3/Database/TestUser.php rename tests/cases/Db/SQLite3/{TestDbDriverCreationSQLite3.php => TestCreation.php} (97%) rename tests/cases/Db/SQLite3/{TestDbDriverSQLite3.php => TestDriver.php} (96%) rename tests/cases/Db/SQLite3/{TestDbResultSQLite3.php => TestResult.php} (87%) rename tests/cases/Db/SQLite3/{TestDbStatementSQLite3.php => TestStatement.php} (91%) rename tests/cases/Db/SQLite3/{TestDbUpdateSQLite3.php => TestUpdate.php} (92%) rename tests/cases/Feed/{TestFeedFetching.php => TestFetching.php} (91%) rename tests/cases/Lang/{TestLang.php => TestBasic.php} (81%) rename tests/cases/Lang/{TestLangErrors.php => TestErrors.php} (88%) rename tests/cases/Lang/{testLangComplex.php => testComplex.php} (92%) rename tests/cases/REST/NextCloudNews/{TestNCNV1_2.php => TestV1_2.php} (99%) rename tests/cases/REST/NextCloudNews/{TestNCNVersionDiscovery.php => TestVersions.php} (85%) rename tests/cases/REST/TinyTinyRSS/{TestTinyTinyAPI.php => TestAPI.php} (99%) rename tests/cases/REST/TinyTinyRSS/{TestTinyTinyIcon.php => TestIcon.php} (88%) rename tests/cases/User/{TestUserMockExternal.php => TestMockExternal.php} (54%) rename tests/cases/User/{TestUserMockInternal.php => TestMockInternal.php} (57%) rename tests/cases/User/{TestUserInternalDriver.php => Testnternal.php} (64%) diff --git a/.php_cs.dist b/.php_cs.dist index 3b915946..90db01f7 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -10,6 +10,7 @@ const BASE = __DIR__.DIRECTORY_SEPARATOR; $paths = [ __FILE__, BASE."arsse.php", + BASE."RoboFile.php", BASE."lib", BASE."tests", ]; diff --git a/RoboFile.php b/RoboFile.php index 02ae1c42..d0d1d24a 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -11,15 +11,15 @@ class RoboFile extends \Robo\Tasks { const BASE = __DIR__.\DIRECTORY_SEPARATOR; const BASE_TEST = self::BASE."tests".\DIRECTORY_SEPARATOR; - /** - * Runs the full test suite - * - * Arguments passed to the task are passed on to PHPUnit. Thus one may, for + /** + * Runs the full test suite + * + * Arguments passed to the task are passed on to PHPUnit. Thus one may, for * example, run the following command and get the expected results: - * - * ./robo test --testsuite TTRSS --exclude-group slow --testdox - * - * Please see the PHPUnit documentation for available options. + * + * ./robo test --testsuite TTRSS --exclude-group slow --testdox + * + * Please see the PHPUnit documentation for available options. */ public function test(array $args): Result { // start the built-in PHP server, which is required for some of the tests @@ -30,32 +30,32 @@ class RoboFile extends \Robo\Tasks { return $this->taskExec("php")->arg($execpath)->option("-c", $confpath)->args($args)->run(); } - /** - * Runs the full test suite - * - * This is an alias of the "test" task. + /** + * Runs the full test suite + * + * This is an alias of the "test" task. */ public function testFull(array $args): Result { return $this->test($args); } - /** - * Runs a quick subset of the test suite - * - * See help for the "test" task for more details. + /** + * Runs a quick subset of the test suite + * + * See help for the "test" task for more details. */ public function testQuick(array $args): Result { return $this->test(array_merge(["--exclude-group", "slow,optional"], $args)); } - /** Produces a code coverage report - * + /** Produces a code coverage report + * * By default this task produces an HTML-format coverage report in * arsse/tests/coverage/. Additional reports may be produced by passing * arguments to this task as one would to PHPUnit. - * + * * Robo first tries to use phpdbg and will fall back to Xdebug if available. - * Because Xdebug slows down non-coverage tasks, however, phpdbg is highly + * Because Xdebug slows down non-coverage tasks, however, phpdbg is highly * recommanded is debugging facilities are not otherwise needed. */ public function coverage(array $args): Result { @@ -79,14 +79,14 @@ class RoboFile extends \Robo\Tasks { } } - /** Packages a given commit of the software into a release tarball - * + /** Packages a given commit of the software into a release tarball + * * The version to package may be any Git tree-ish identifier: a tag, a branch, * or any commit hash. If none is provided on the command line, Robo will prompt * for a commit to package; the default is "head". - * + * * Note that while it is possible to re-package old versions, the resultant tarball - * may not be equivalent due to subsequent changes in the exclude list, or because + * may not be equivalent due to subsequent changes in the exclude list, or because * of new tooling. */ public function package(string $version = null): Result { @@ -128,4 +128,13 @@ class RoboFile extends \Robo\Tasks { $this->_exec("git worktree prune"); return $out; } -} \ No newline at end of file + + public function clean($opts = ['demo|d' => false]): Result { + $t = $this->taskExec(realpath(self::BASE."vendor/bin/php-cs-fixer")); + $t->arg("fix"); + if ($opts['demo']) { + $t->args("--dry-run", "--diff")->option("--diff-format", "udiff"); + } + return $t->run(); + } +} diff --git a/robo b/robo index ab928f77..7d4d4d76 100755 --- a/robo +++ b/robo @@ -3,4 +3,8 @@ base=`dirname "$0"` roboCommand="$1" shift -"$base/vendor/bin/robo" "$roboCommand" -- $* \ No newline at end of file +if [ "$1" == "clean" ]; then + "$base/vendor/bin/robo" "$roboCommand" $* +else + "$base/vendor/bin/robo" "$roboCommand" -- $* +fi \ No newline at end of file diff --git a/robo.bat b/robo.bat index f0c1de40..297f9545 100644 --- a/robo.bat +++ b/robo.bat @@ -14,4 +14,8 @@ if "%~1" neq "" ( ) if defined args set args=%args:~1% -call "%base%vendor\bin\robo" "%roboCommand%" -- %args% \ No newline at end of file +if "%1"=="clean" ( + call "%base%vendor\bin\robo" "%roboCommand%" %args% +) else ( + call "%base%vendor\bin\robo" "%roboCommand%" -- %args% +) diff --git a/tests/cases/Conf/TestConf.php b/tests/cases/Conf/TestConf.php index d03e79c4..edfcfbbc 100644 --- a/tests/cases/Conf/TestConf.php +++ b/tests/cases/Conf/TestConf.php @@ -4,12 +4,13 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Conf; +use JKingWeb\Arsse\Conf; use org\bovigo\vfs\vfsStream; /** @covers \JKingWeb\Arsse\Conf */ -class TestConf extends Test\AbstractTest { +class TestConf extends \JKingWeb\Arsse\Test\AbstractTest { public static $vfs; public static $path; diff --git a/tests/cases/Db/SQLite3/Database/TestArticle.php b/tests/cases/Db/SQLite3/Database/TestArticle.php new file mode 100644 index 00000000..67480adf --- /dev/null +++ b/tests/cases/Db/SQLite3/Database/TestArticle.php @@ -0,0 +1,14 @@ + */ +class TestArticle extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Database\Setup; + use \JKingWeb\Arsse\Test\Database\DriverSQLite3; + use \JKingWeb\Arsse\Test\Database\SeriesArticle; +} diff --git a/tests/cases/Db/SQLite3/Database/TestCleanup.php b/tests/cases/Db/SQLite3/Database/TestCleanup.php new file mode 100644 index 00000000..3ecba415 --- /dev/null +++ b/tests/cases/Db/SQLite3/Database/TestCleanup.php @@ -0,0 +1,14 @@ + */ +class TestCleanup extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Database\Setup; + use \JKingWeb\Arsse\Test\Database\DriverSQLite3; + use \JKingWeb\Arsse\Test\Database\SeriesCleanup; +} diff --git a/tests/cases/Db/SQLite3/Database/TestDatabaseArticleSQLite3.php b/tests/cases/Db/SQLite3/Database/TestDatabaseArticleSQLite3.php deleted file mode 100644 index 9c013e93..00000000 --- a/tests/cases/Db/SQLite3/Database/TestDatabaseArticleSQLite3.php +++ /dev/null @@ -1,14 +0,0 @@ - */ -class TestDatabaseArticleSQLite3 extends Test\AbstractTest { - use Test\Database\Setup; - use Test\Database\DriverSQLite3; - use Test\Database\SeriesArticle; -} diff --git a/tests/cases/Db/SQLite3/Database/TestDatabaseCleanupSQLite3.php b/tests/cases/Db/SQLite3/Database/TestDatabaseCleanupSQLite3.php deleted file mode 100644 index 09c99884..00000000 --- a/tests/cases/Db/SQLite3/Database/TestDatabaseCleanupSQLite3.php +++ /dev/null @@ -1,14 +0,0 @@ - */ -class TestDatabaseCleanupSQLite3 extends Test\AbstractTest { - use Test\Database\Setup; - use Test\Database\DriverSQLite3; - use Test\Database\SeriesCleanup; -} diff --git a/tests/cases/Db/SQLite3/Database/TestDatabaseFeedSQLite3.php b/tests/cases/Db/SQLite3/Database/TestDatabaseFeedSQLite3.php deleted file mode 100644 index a91286a9..00000000 --- a/tests/cases/Db/SQLite3/Database/TestDatabaseFeedSQLite3.php +++ /dev/null @@ -1,14 +0,0 @@ - */ -class TestDatabaseFeedSQLite3 extends Test\AbstractTest { - use Test\Database\Setup; - use Test\Database\DriverSQLite3; - use Test\Database\SeriesFeed; -} diff --git a/tests/cases/Db/SQLite3/Database/TestDatabaseFolderSQLite3.php b/tests/cases/Db/SQLite3/Database/TestDatabaseFolderSQLite3.php deleted file mode 100644 index d10aafc9..00000000 --- a/tests/cases/Db/SQLite3/Database/TestDatabaseFolderSQLite3.php +++ /dev/null @@ -1,14 +0,0 @@ - */ -class TestDatabaseFolderSQLite3 extends Test\AbstractTest { - use Test\Database\Setup; - use Test\Database\DriverSQLite3; - use Test\Database\SeriesFolder; -} diff --git a/tests/cases/Db/SQLite3/Database/TestDatabaseLabelSQLite3.php b/tests/cases/Db/SQLite3/Database/TestDatabaseLabelSQLite3.php deleted file mode 100644 index 815bd490..00000000 --- a/tests/cases/Db/SQLite3/Database/TestDatabaseLabelSQLite3.php +++ /dev/null @@ -1,10 +0,0 @@ - */ -class TestDatabaseLabelSQLite3 extends Test\AbstractTest { - use Test\Database\Setup; - use Test\Database\DriverSQLite3; - use Test\Database\SeriesLabel; -} diff --git a/tests/cases/Db/SQLite3/Database/TestDatabaseMetaSQLite3.php b/tests/cases/Db/SQLite3/Database/TestDatabaseMetaSQLite3.php deleted file mode 100644 index 2dbd1721..00000000 --- a/tests/cases/Db/SQLite3/Database/TestDatabaseMetaSQLite3.php +++ /dev/null @@ -1,14 +0,0 @@ - */ -class TestDatabaseMetaSQLite3 extends Test\AbstractTest { - use Test\Database\Setup; - use Test\Database\DriverSQLite3; - use Test\Database\SeriesMeta; -} diff --git a/tests/cases/Db/SQLite3/Database/TestDatabaseMiscellanySQLite3.php b/tests/cases/Db/SQLite3/Database/TestDatabaseMiscellanySQLite3.php deleted file mode 100644 index cc8eb089..00000000 --- a/tests/cases/Db/SQLite3/Database/TestDatabaseMiscellanySQLite3.php +++ /dev/null @@ -1,14 +0,0 @@ - */ -class TestDatabaseMiscellanySQLite3 extends Test\AbstractTest { - use Test\Database\Setup; - use Test\Database\DriverSQLite3; - use Test\Database\SeriesMiscellany; -} diff --git a/tests/cases/Db/SQLite3/Database/TestDatabaseSessionSQLite3.php b/tests/cases/Db/SQLite3/Database/TestDatabaseSessionSQLite3.php deleted file mode 100644 index be10b889..00000000 --- a/tests/cases/Db/SQLite3/Database/TestDatabaseSessionSQLite3.php +++ /dev/null @@ -1,10 +0,0 @@ - */ -class TestDatabaseSessionSQLite3 extends Test\AbstractTest { - use Test\Database\Setup; - use Test\Database\DriverSQLite3; - use Test\Database\SeriesSession; -} diff --git a/tests/cases/Db/SQLite3/Database/TestDatabaseSubscriptionSQLite3.php b/tests/cases/Db/SQLite3/Database/TestDatabaseSubscriptionSQLite3.php deleted file mode 100644 index 54cc11c2..00000000 --- a/tests/cases/Db/SQLite3/Database/TestDatabaseSubscriptionSQLite3.php +++ /dev/null @@ -1,14 +0,0 @@ - */ -class TestDatabaseSubscriptionSQLite3 extends Test\AbstractTest { - use Test\Database\Setup; - use Test\Database\DriverSQLite3; - use Test\Database\SeriesSubscription; -} diff --git a/tests/cases/Db/SQLite3/Database/TestDatabaseUserSQLite3.php b/tests/cases/Db/SQLite3/Database/TestDatabaseUserSQLite3.php deleted file mode 100644 index 5898c4e2..00000000 --- a/tests/cases/Db/SQLite3/Database/TestDatabaseUserSQLite3.php +++ /dev/null @@ -1,14 +0,0 @@ - */ -class TestDatabaseUserSQLite3 extends Test\AbstractTest { - use Test\Database\Setup; - use Test\Database\DriverSQLite3; - use Test\Database\SeriesUser; -} diff --git a/tests/cases/Db/SQLite3/Database/TestFeed.php b/tests/cases/Db/SQLite3/Database/TestFeed.php new file mode 100644 index 00000000..0d5bc9d9 --- /dev/null +++ b/tests/cases/Db/SQLite3/Database/TestFeed.php @@ -0,0 +1,14 @@ + */ +class TestFeed extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Database\Setup; + use \JKingWeb\Arsse\Test\Database\DriverSQLite3; + use \JKingWeb\Arsse\Test\Database\SeriesFeed; +} diff --git a/tests/cases/Db/SQLite3/Database/TestFolder.php b/tests/cases/Db/SQLite3/Database/TestFolder.php new file mode 100644 index 00000000..0f6c2a88 --- /dev/null +++ b/tests/cases/Db/SQLite3/Database/TestFolder.php @@ -0,0 +1,14 @@ + */ +class TestFolder extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Database\Setup; + use \JKingWeb\Arsse\Test\Database\DriverSQLite3; + use \JKingWeb\Arsse\Test\Database\SeriesFolder; +} diff --git a/tests/cases/Db/SQLite3/Database/TestLabel.php b/tests/cases/Db/SQLite3/Database/TestLabel.php new file mode 100644 index 00000000..2f5af8d1 --- /dev/null +++ b/tests/cases/Db/SQLite3/Database/TestLabel.php @@ -0,0 +1,10 @@ + */ +class TestLabel extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Database\Setup; + use \JKingWeb\Arsse\Test\Database\DriverSQLite3; + use \JKingWeb\Arsse\Test\Database\SeriesLabel; +} diff --git a/tests/cases/Db/SQLite3/Database/TestMeta.php b/tests/cases/Db/SQLite3/Database/TestMeta.php new file mode 100644 index 00000000..17f8900d --- /dev/null +++ b/tests/cases/Db/SQLite3/Database/TestMeta.php @@ -0,0 +1,14 @@ + */ +class TestMeta extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Database\Setup; + use \JKingWeb\Arsse\Test\Database\DriverSQLite3; + use \JKingWeb\Arsse\Test\Database\SeriesMeta; +} diff --git a/tests/cases/Db/SQLite3/Database/TestMiscellany.php b/tests/cases/Db/SQLite3/Database/TestMiscellany.php new file mode 100644 index 00000000..d9b408cf --- /dev/null +++ b/tests/cases/Db/SQLite3/Database/TestMiscellany.php @@ -0,0 +1,14 @@ + */ +class TestMiscellany extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Database\Setup; + use \JKingWeb\Arsse\Test\Database\DriverSQLite3; + use \JKingWeb\Arsse\Test\Database\SeriesMiscellany; +} diff --git a/tests/cases/Db/SQLite3/Database/TestSession.php b/tests/cases/Db/SQLite3/Database/TestSession.php new file mode 100644 index 00000000..22600abd --- /dev/null +++ b/tests/cases/Db/SQLite3/Database/TestSession.php @@ -0,0 +1,10 @@ + */ +class TestSession extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Database\Setup; + use \JKingWeb\Arsse\Test\Database\DriverSQLite3; + use \JKingWeb\Arsse\Test\Database\SeriesSession; +} diff --git a/tests/cases/Db/SQLite3/Database/TestSubscription.php b/tests/cases/Db/SQLite3/Database/TestSubscription.php new file mode 100644 index 00000000..9f91cafb --- /dev/null +++ b/tests/cases/Db/SQLite3/Database/TestSubscription.php @@ -0,0 +1,14 @@ + */ +class TestSubscription extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Database\Setup; + use \JKingWeb\Arsse\Test\Database\DriverSQLite3; + use \JKingWeb\Arsse\Test\Database\SeriesSubscription; +} diff --git a/tests/cases/Db/SQLite3/Database/TestUser.php b/tests/cases/Db/SQLite3/Database/TestUser.php new file mode 100644 index 00000000..02042128 --- /dev/null +++ b/tests/cases/Db/SQLite3/Database/TestUser.php @@ -0,0 +1,14 @@ + */ +class TestUser extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Database\Setup; + use \JKingWeb\Arsse\Test\Database\DriverSQLite3; + use \JKingWeb\Arsse\Test\Database\SeriesUser; +} diff --git a/tests/cases/Db/SQLite3/TestDbDriverCreationSQLite3.php b/tests/cases/Db/SQLite3/TestCreation.php similarity index 97% rename from tests/cases/Db/SQLite3/TestDbDriverCreationSQLite3.php rename to tests/cases/Db/SQLite3/TestCreation.php index ebd92498..4f04918f 100644 --- a/tests/cases/Db/SQLite3/TestDbDriverCreationSQLite3.php +++ b/tests/cases/Db/SQLite3/TestCreation.php @@ -4,9 +4,10 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Db\SQLite3; use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Conf; use JKingWeb\Arsse\Db\SQLite3\Driver; use org\bovigo\vfs\vfsStream; use Phake; @@ -14,7 +15,7 @@ use Phake; /** * @covers \JKingWeb\Arsse\Db\SQLite3\Driver * @covers \JKingWeb\Arsse\Db\SQLite3\ExceptionBuilder */ -class TestDbDriverCreationSQLite3 extends Test\AbstractTest { +class TestCreation extends \JKingWeb\Arsse\Test\AbstractTest { protected $data; protected $drv; protected $ch; diff --git a/tests/cases/Db/SQLite3/TestDbDriverSQLite3.php b/tests/cases/Db/SQLite3/TestDriver.php similarity index 96% rename from tests/cases/Db/SQLite3/TestDbDriverSQLite3.php rename to tests/cases/Db/SQLite3/TestDriver.php index 224f2cca..d2e602ce 100644 --- a/tests/cases/Db/SQLite3/TestDbDriverSQLite3.php +++ b/tests/cases/Db/SQLite3/TestDriver.php @@ -4,12 +4,19 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Db\SQLite3; + +use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Conf; +use JKingWeb\Arsse\Database; +use JKingWeb\Arsse\Db\SQLite3\Driver; +use JKingWeb\Arsse\Db\SQLite3\Result; +use JKingWeb\Arsse\Db\SQLite3\Statement; /** * @covers \JKingWeb\Arsse\Db\SQLite3\Driver * @covers \JKingWeb\Arsse\Db\SQLite3\ExceptionBuilder */ -class TestDbDriverSQLite3 extends Test\AbstractTest { +class TestDriver extends \JKingWeb\Arsse\Test\AbstractTest { protected $data; protected $drv; protected $ch; @@ -21,10 +28,10 @@ class TestDbDriverSQLite3 extends Test\AbstractTest { $this->clearData(); $conf = new Conf(); Arsse::$conf = $conf; - $conf->dbDriver = Db\SQLite3\Driver::class; + $conf->dbDriver = Driver::class; $conf->dbSQLite3Timeout = 0; $conf->dbSQLite3File = tempnam(sys_get_temp_dir(), 'ook'); - $this->drv = new Db\SQLite3\Driver(); + $this->drv = new Driver(); $this->ch = new \SQLite3(Arsse::$conf->dbSQLite3File); $this->ch->enableExceptions(true); } @@ -80,7 +87,7 @@ class TestDbDriverSQLite3 extends Test\AbstractTest { } public function testMakeAValidQuery() { - $this->assertInstanceOf(Db\Result::class, $this->drv->query("SELECT 1")); + $this->assertInstanceOf(Result::class, $this->drv->query("SELECT 1")); } public function testMakeAnInvalidQuery() { @@ -108,7 +115,7 @@ class TestDbDriverSQLite3 extends Test\AbstractTest { public function testPrepareAValidQuery() { $s = $this->drv->prepare("SELECT ?, ?", "int", "int"); - $this->assertInstanceOf(Db\Statement::class, $s); + $this->assertInstanceOf(Statement::class, $s); } public function testPrepareAnInvalidQuery() { diff --git a/tests/cases/Db/SQLite3/TestDbResultSQLite3.php b/tests/cases/Db/SQLite3/TestResult.php similarity index 87% rename from tests/cases/Db/SQLite3/TestDbResultSQLite3.php rename to tests/cases/Db/SQLite3/TestResult.php index 31b5bca8..3b841f16 100644 --- a/tests/cases/Db/SQLite3/TestDbResultSQLite3.php +++ b/tests/cases/Db/SQLite3/TestResult.php @@ -4,10 +4,12 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Db\SQLite3; + +use JKingWeb\Arsse\Db\SQLite3\Result; /** @covers \JKingWeb\Arsse\Db\SQLite3\Result */ -class TestDbResultSQLite3 extends Test\AbstractTest { +class TestResult extends \JKingWeb\Arsse\Test\AbstractTest { protected $c; public function setUp() { @@ -28,7 +30,7 @@ class TestDbResultSQLite3 extends Test\AbstractTest { public function testConstructResult() { $set = $this->c->query("SELECT 1"); - $this->assertInstanceOf(Db\Result::class, new Db\SQLite3\Result($set)); + $this->assertInstanceOf(Result::class, new Result($set)); } public function testGetChangeCountAndLastInsertId() { @@ -36,7 +38,7 @@ class TestDbResultSQLite3 extends Test\AbstractTest { $set = $this->c->query("INSERT INTO test(col) values(1)"); $rows = $this->c->changes(); $id = $this->c->lastInsertRowID(); - $r = new Db\SQLite3\Result($set, [$rows,$id]); + $r = new Result($set, [$rows,$id]); $this->assertEquals($rows, $r->changes()); $this->assertEquals($id, $r->lastId()); } @@ -44,7 +46,7 @@ class TestDbResultSQLite3 extends Test\AbstractTest { public function testIterateOverResults() { $set = $this->c->query("SELECT 1 as col union select 2 as col union select 3 as col"); $rows = []; - foreach (new Db\SQLite3\Result($set) as $index => $row) { + foreach (new Result($set) as $index => $row) { $rows[$index] = $row['col']; } $this->assertEquals([0 => 1, 1 => 2, 2 => 3], $rows); @@ -53,7 +55,7 @@ class TestDbResultSQLite3 extends Test\AbstractTest { public function testIterateOverResultsTwice() { $set = $this->c->query("SELECT 1 as col union select 2 as col union select 3 as col"); $rows = []; - $test = new Db\SQLite3\Result($set); + $test = new Result($set); foreach ($test as $row) { $rows[] = $row['col']; } @@ -66,7 +68,7 @@ class TestDbResultSQLite3 extends Test\AbstractTest { public function testGetSingleValues() { $set = $this->c->query("SELECT 1867 as year union select 1970 as year union select 2112 as year"); - $test = new Db\SQLite3\Result($set); + $test = new Result($set); $this->assertEquals(1867, $test->getValue()); $this->assertEquals(1970, $test->getValue()); $this->assertEquals(2112, $test->getValue()); @@ -75,7 +77,7 @@ class TestDbResultSQLite3 extends Test\AbstractTest { public function testGetFirstValuesOnly() { $set = $this->c->query("SELECT 1867 as year, 19 as century union select 1970 as year, 20 as century union select 2112 as year, 22 as century"); - $test = new Db\SQLite3\Result($set); + $test = new Result($set); $this->assertEquals(1867, $test->getValue()); $this->assertEquals(1970, $test->getValue()); $this->assertEquals(2112, $test->getValue()); @@ -88,7 +90,7 @@ class TestDbResultSQLite3 extends Test\AbstractTest { ['album' => '2112', 'track' => '2112'], ['album' => 'Clockwork Angels', 'track' => 'The Wreckers'], ]; - $test = new Db\SQLite3\Result($set); + $test = new Result($set); $this->assertEquals($rows[0], $test->getRow()); $this->assertEquals($rows[1], $test->getRow()); $this->assertSame(null, $test->getRow()); @@ -100,7 +102,7 @@ class TestDbResultSQLite3 extends Test\AbstractTest { ['album' => '2112', 'track' => '2112'], ['album' => 'Clockwork Angels', 'track' => 'The Wreckers'], ]; - $test = new Db\SQLite3\Result($set); + $test = new Result($set); $this->assertEquals($rows, $test->getAll()); } } diff --git a/tests/cases/Db/SQLite3/TestDbStatementSQLite3.php b/tests/cases/Db/SQLite3/TestStatement.php similarity index 91% rename from tests/cases/Db/SQLite3/TestDbStatementSQLite3.php rename to tests/cases/Db/SQLite3/TestStatement.php index cc92883d..7e722c2d 100644 --- a/tests/cases/Db/SQLite3/TestDbStatementSQLite3.php +++ b/tests/cases/Db/SQLite3/TestStatement.php @@ -4,18 +4,18 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Db\SQLite3; use JKingWeb\Arsse\Db\Statement; /** * @covers \JKingWeb\Arsse\Db\SQLite3\Statement * @covers \JKingWeb\Arsse\Db\SQLite3\ExceptionBuilder */ -class TestDbStatementSQLite3 extends Test\AbstractTest { - use Test\Db\BindingTests; +class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Db\BindingTests; protected $c; - protected static $imp = Db\SQLite3\Statement::class; + protected static $imp = \JKingWeb\Arsse\Db\SQLite3\Statement::class; public function setUp() { $this->clearData(); @@ -48,7 +48,7 @@ class TestDbStatementSQLite3 extends Test\AbstractTest { public function testConstructStatement() { $nativeStatement = $this->c->prepare("SELECT ? as value"); - $this->assertInstanceOf(Statement::class, new Db\SQLite3\Statement($this->c, $nativeStatement)); + $this->assertInstanceOf(Statement::class, new \JKingWeb\Arsse\Db\SQLite3\Statement($this->c, $nativeStatement)); } public function testBindMissingValue() { diff --git a/tests/cases/Db/SQLite3/TestDbUpdateSQLite3.php b/tests/cases/Db/SQLite3/TestUpdate.php similarity index 92% rename from tests/cases/Db/SQLite3/TestDbUpdateSQLite3.php rename to tests/cases/Db/SQLite3/TestUpdate.php index 7c48d2fe..3767d75e 100644 --- a/tests/cases/Db/SQLite3/TestDbUpdateSQLite3.php +++ b/tests/cases/Db/SQLite3/TestUpdate.php @@ -4,14 +4,19 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Db\SQLite3; +use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Conf; +use JKingWeb\Arsse\Database; +use JKingWeb\Arsse\Db\Exception; +use JKingWeb\Arsse\Db\SQLite3\Driver; use org\bovigo\vfs\vfsStream; /** * @covers \JKingWeb\Arsse\Db\SQLite3\Driver * @covers \JKingWeb\Arsse\Db\SQLite3\ExceptionBuilder */ -class TestDbUpdateSQLite3 extends Test\AbstractTest { +class TestUpdate extends \JKingWeb\Arsse\Test\AbstractTest { protected $data; protected $drv; protected $vfs; @@ -29,12 +34,12 @@ class TestDbUpdateSQLite3 extends Test\AbstractTest { if (!$conf) { $conf = new Conf(); } - $conf->dbDriver = Db\SQLite3\Driver::class; + $conf->dbDriver = Driver::class; $conf->dbSQLite3File = ":memory:"; Arsse::$conf = $conf; $this->base = $this->vfs->url(); $this->path = $this->base."/SQLite3/"; - $this->drv = new Db\SQLite3\Driver(); + $this->drv = new Driver(); } public function tearDown() { diff --git a/tests/cases/Db/TestResultAggregate.php b/tests/cases/Db/TestResultAggregate.php index a44121ea..cb450ac8 100644 --- a/tests/cases/Db/TestResultAggregate.php +++ b/tests/cases/Db/TestResultAggregate.php @@ -1,18 +1,19 @@ */ -class TestResultAggregate extends Test\AbstractTest { +class TestResultAggregate extends \JKingWeb\Arsse\Test\AbstractTest { public function testGetChangeCountAndLastInsertId() { $in = [ new Result([], 3, 4), new Result([], 27, 10), new Result([], 12, 2112), ]; - $r = new Db\ResultAggregate(...$in); + $r = new ResultAggregate(...$in); $this->assertEquals(42, $r->changes()); $this->assertEquals(2112, $r->lastId()); } @@ -24,7 +25,7 @@ class TestResultAggregate extends Test\AbstractTest { new Result([['col' => 3]]), ]; $rows = []; - foreach (new Db\ResultAggregate(...$in) as $index => $row) { + foreach (new ResultAggregate(...$in) as $index => $row) { $rows[$index] = $row['col']; } $this->assertEquals([0 => 1, 1 => 2, 2 => 3], $rows); @@ -37,7 +38,7 @@ class TestResultAggregate extends Test\AbstractTest { new Result([['col' => 3]]), ]; $rows = []; - $test = new Db\ResultAggregate(...$in); + $test = new ResultAggregate(...$in); foreach ($test as $row) { $rows[] = $row['col']; } @@ -49,7 +50,7 @@ class TestResultAggregate extends Test\AbstractTest { } public function testGetSingleValues() { - $test = new Db\ResultAggregate(...[ + $test = new ResultAggregate(...[ new Result([['year' => 1867]]), new Result([['year' => 1970]]), new Result([['year' => 2112]]), @@ -61,7 +62,7 @@ class TestResultAggregate extends Test\AbstractTest { } public function testGetFirstValuesOnly() { - $test = new Db\ResultAggregate(...[ + $test = new ResultAggregate(...[ new Result([['year' => 1867, 'century' => 19]]), new Result([['year' => 1970, 'century' => 20]]), new Result([['year' => 2112, 'century' => 22]]), @@ -73,7 +74,7 @@ class TestResultAggregate extends Test\AbstractTest { } public function testGetRows() { - $test = new Db\ResultAggregate(...[ + $test = new ResultAggregate(...[ new Result([['album' => '2112', 'track' => '2112']]), new Result([['album' => 'Clockwork Angels', 'track' => 'The Wreckers']]), ]); @@ -87,7 +88,7 @@ class TestResultAggregate extends Test\AbstractTest { } public function testGetAllRows() { - $test = new Db\ResultAggregate(...[ + $test = new ResultAggregate(...[ new Result([['album' => '2112', 'track' => '2112']]), new Result([['album' => 'Clockwork Angels', 'track' => 'The Wreckers']]), ]); diff --git a/tests/cases/Db/TestResultEmpty.php b/tests/cases/Db/TestResultEmpty.php index 65b1380b..03df4d40 100644 --- a/tests/cases/Db/TestResultEmpty.php +++ b/tests/cases/Db/TestResultEmpty.php @@ -1,35 +1,37 @@ */ -class TestResultEmpty extends Test\AbstractTest { +class TestResultEmpty extends \JKingWeb\Arsse\Test\AbstractTest { public function testGetChangeCountAndLastInsertId() { - $r = new Db\ResultEmpty; + $r = new ResultEmpty; $this->assertEquals(0, $r->changes()); $this->assertEquals(0, $r->lastId()); } public function testIterateOverResults() { $rows = []; - foreach (new Db\ResultEmpty as $index => $row) { + foreach (new ResultEmpty as $index => $row) { $rows[$index] = $row['col']; } $this->assertEquals([], $rows); } public function testGetSingleValues() { - $test = new Db\ResultEmpty; + $test = new ResultEmpty; $this->assertSame(null, $test->getValue()); } public function testGetRows() { - $test = new Db\ResultEmpty; + $test = new ResultEmpty; $this->assertSame(null, $test->getRow()); } public function testGetAllRows() { - $test = new Db\ResultEmpty; + $test = new ResultEmpty; $rows = []; $this->assertEquals($rows, $test->getAll()); } diff --git a/tests/cases/Db/TestTransaction.php b/tests/cases/Db/TestTransaction.php index 118e3e8e..9469d6c2 100644 --- a/tests/cases/Db/TestTransaction.php +++ b/tests/cases/Db/TestTransaction.php @@ -4,19 +4,20 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Db; use JKingWeb\Arsse\Db\Transaction; +use JKingWeb\Arsse\Db\Exception; use Phake; /** * @covers \JKingWeb\Arsse\Db\Transaction */ -class TestTransaction extends Test\AbstractTest { +class TestTransaction extends \JKingWeb\Arsse\Test\AbstractTest { protected $drv; public function setUp() { $this->clearData(); - $drv = Phake::mock(Db\SQLite3\Driver::class); + $drv = Phake::mock(\JKingWeb\Arsse\Db\SQLite3\Driver::class); Phake::when($drv)->savepointRelease->thenReturn(true); Phake::when($drv)->savepointUndo->thenReturn(true); Phake::when($drv)->savepointCreate->thenReturn(1)->thenReturn(2); @@ -51,7 +52,7 @@ class TestTransaction extends Test\AbstractTest { } public function testIgnoreRollbackErrors() { - Phake::when($this->drv)->savepointUndo->thenThrow(new Db\Exception("savepointStale")); + Phake::when($this->drv)->savepointUndo->thenThrow(new Exception("savepointStale")); $tr1 = new Transaction($this->drv); $tr2 = new Transaction($this->drv); unset($tr1, $tr2); // no exception should bubble up diff --git a/tests/cases/Exception/TestException.php b/tests/cases/Exception/TestException.php index 821280f3..6dba7034 100644 --- a/tests/cases/Exception/TestException.php +++ b/tests/cases/Exception/TestException.php @@ -4,12 +4,16 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Exception; +use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Lang; +use JKingWeb\Arsse\Exception; +use JKingWeb\Arsse\Lang\Exception as LangException; use Phake; /** @covers \JKingWeb\Arsse\AbstractException */ -class TestException extends Test\AbstractTest { +class TestException extends \JKingWeb\Arsse\Test\AbstractTest { public function setUp() { $this->clearData(false); // create a mock Lang object so as not to create a dependency loop @@ -43,7 +47,7 @@ class TestException extends Test\AbstractTest { */ public function testDerivedClass() { $this->assertException("fileMissing", "Lang"); - throw new Lang\Exception("fileMissing"); + throw new LangException("fileMissing"); } /** @@ -51,7 +55,7 @@ class TestException extends Test\AbstractTest { */ public function testDerivedClassWithMessageParameters() { $this->assertException("fileMissing", "Lang"); - throw new Lang\Exception("fileMissing", "en"); + throw new LangException("fileMissing", "en"); } /** @@ -67,6 +71,6 @@ class TestException extends Test\AbstractTest { */ public function testDerivedClassWithMissingMessage() { $this->assertException("uncoded"); - throw new Lang\Exception("testThisExceptionMessageDoesNotExist"); + throw new LangException("testThisExceptionMessageDoesNotExist"); } } diff --git a/tests/cases/Feed/TestFeed.php b/tests/cases/Feed/TestFeed.php index 23e89f93..d458c4ac 100644 --- a/tests/cases/Feed/TestFeed.php +++ b/tests/cases/Feed/TestFeed.php @@ -4,16 +4,21 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Feed; +use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Conf; +use JKingWeb\Arsse\Feed; +use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Misc\Date; +use JKingWeb\Arsse\Test\Result; use Phake; /** * @covers \JKingWeb\Arsse\Feed * @covers \JKingWeb\Arsse\Feed\Exception * @group slow */ -class TestFeed extends Test\AbstractTest { +class TestFeed extends \JKingWeb\Arsse\Test\AbstractTest { protected static $host = "http://localhost:8000/"; protected $base = ""; protected $latest = [ @@ -329,7 +334,7 @@ class TestFeed extends Test\AbstractTest { } public function testMatchLatestArticles() { - Phake::when(Arsse::$db)->feedMatchLatest(1, $this->anything())->thenReturn(new Test\Result($this->latest)); + Phake::when(Arsse::$db)->feedMatchLatest(1, $this->anything())->thenReturn(new Result($this->latest)); $f = new Feed(1, $this->base."Matching/1"); $this->assertCount(0, $f->newItems); $this->assertCount(0, $f->changedItems); @@ -345,8 +350,8 @@ class TestFeed extends Test\AbstractTest { } public function testMatchHistoricalArticles() { - Phake::when(Arsse::$db)->feedMatchLatest(1, $this->anything())->thenReturn(new Test\Result($this->latest)); - Phake::when(Arsse::$db)->feedMatchIds(1, $this->anything(), $this->anything(), $this->anything(), $this->anything())->thenReturn(new Test\Result($this->others)); + Phake::when(Arsse::$db)->feedMatchLatest(1, $this->anything())->thenReturn(new Result($this->latest)); + Phake::when(Arsse::$db)->feedMatchIds(1, $this->anything(), $this->anything(), $this->anything(), $this->anything())->thenReturn(new Result($this->others)); $f = new Feed(1, $this->base."Matching/5"); $this->assertCount(0, $f->newItems); $this->assertCount(0, $f->changedItems); diff --git a/tests/cases/Feed/TestFeedFetching.php b/tests/cases/Feed/TestFetching.php similarity index 91% rename from tests/cases/Feed/TestFeedFetching.php rename to tests/cases/Feed/TestFetching.php index e5de5043..afe1391a 100644 --- a/tests/cases/Feed/TestFeedFetching.php +++ b/tests/cases/Feed/TestFetching.php @@ -4,14 +4,17 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Feed; +use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Conf; +use JKingWeb\Arsse\Feed; use Phake; -/** - * @covers \JKingWeb\Arsse\Feed +/** + * @covers \JKingWeb\Arsse\Feed * @group slow */ -class TestFeedFetching extends Test\AbstractTest { +class TestFetching extends \JKingWeb\Arsse\Test\AbstractTest { protected static $host = "http://localhost:8000/"; protected $base = ""; diff --git a/tests/cases/Lang/TestLang.php b/tests/cases/Lang/TestBasic.php similarity index 81% rename from tests/cases/Lang/TestLang.php rename to tests/cases/Lang/TestBasic.php index 4e6db2a6..fbd71291 100644 --- a/tests/cases/Lang/TestLang.php +++ b/tests/cases/Lang/TestBasic.php @@ -4,13 +4,15 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Lang; +use JKingWeb\Arsse\Lang as TestClass; use org\bovigo\vfs\vfsStream; + /** @covers \JKingWeb\Arsse\Lang */ -class TestLang extends Test\AbstractTest { - use Test\Lang\Setup; +class TestBasic extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Lang\Setup; public $files; public $path; @@ -38,14 +40,14 @@ class TestLang extends Test\AbstractTest { */ public function testLoadInternalStrings() { $this->assertEquals("", $this->l->set("", true)); - $this->assertCount(sizeof(Lang::REQUIRED), $this->l->dump()); + $this->assertCount(sizeof(TestClass::REQUIRED), $this->l->dump()); } /** * @depends testLoadInternalStrings */ public function testLoadDefaultLanguage() { - $this->assertEquals(Lang::DEFAULT, $this->l->set(Lang::DEFAULT, true)); + $this->assertEquals(TestClass::DEFAULT, $this->l->set(TestClass::DEFAULT, true)); $str = $this->l->dump(); $this->assertArrayHasKey('Exception.JKingWeb/Arsse/Exception.uncoded', $str); $this->assertArrayHasKey('Test.presentText', $str); @@ -55,7 +57,7 @@ class TestLang extends Test\AbstractTest { * @depends testLoadDefaultLanguage */ public function testLoadSupplementaryLanguage() { - $this->l->set(Lang::DEFAULT, true); + $this->l->set(TestClass::DEFAULT, true); $this->assertEquals("ja", $this->l->set("ja", true)); $str = $this->l->dump(); $this->assertArrayHasKey('Exception.JKingWeb/Arsse/Exception.uncoded', $str); diff --git a/tests/cases/Lang/TestLangErrors.php b/tests/cases/Lang/TestErrors.php similarity index 88% rename from tests/cases/Lang/TestLangErrors.php rename to tests/cases/Lang/TestErrors.php index 5051a7fc..bd3f8c03 100644 --- a/tests/cases/Lang/TestLangErrors.php +++ b/tests/cases/Lang/TestErrors.php @@ -4,13 +4,14 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Lang; +use JKingWeb\Arsse\Lang as TestClass; use org\bovigo\vfs\vfsStream; /** @covers \JKingWeb\Arsse\Lang */ -class TestLangErrors extends Test\AbstractTest { - use Test\Lang\Setup; +class TestErrors extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Lang\Setup; public $files; public $path; @@ -62,7 +63,7 @@ class TestLangErrors extends Test\AbstractTest { } public function testLoadMissingDefaultLanguage() { - unlink($this->path.Lang::DEFAULT.".php"); + unlink($this->path.TestClass::DEFAULT.".php"); $this->assertException("defaultFileMissing", "Lang"); $this->l->set("fr", true); } diff --git a/tests/cases/Lang/testLangComplex.php b/tests/cases/Lang/testComplex.php similarity index 92% rename from tests/cases/Lang/testLangComplex.php rename to tests/cases/Lang/testComplex.php index d4399df0..73ae9b08 100644 --- a/tests/cases/Lang/testLangComplex.php +++ b/tests/cases/Lang/testComplex.php @@ -4,20 +4,21 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Lang; +use JKingWeb\Arsse\Lang as TestClass; use org\bovigo\vfs\vfsStream; /** @covers \JKingWeb\Arsse\Lang */ -class TestLangComplex extends Test\AbstractTest { - use Test\Lang\Setup; +class TestComplex extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\Lang\Setup; public $files; public $path; public $l; public function setUpSeries() { - $this->l->set(Lang::DEFAULT, true); + $this->l->set(TestClass::DEFAULT, true); } public function testLazyLoad() { @@ -68,7 +69,7 @@ class TestLangComplex extends Test\AbstractTest { */ public function testFetchAMessageWithSingleNumericParameter() { $this->l->set("en_ca", true); - $this->assertEquals('Default language file "en" missing', $this->l->msg('Exception.JKingWeb/Arsse/Lang/Exception.defaultFileMissing', Lang::DEFAULT)); + $this->assertEquals('Default language file "en" missing', $this->l->msg('Exception.JKingWeb/Arsse/Lang/Exception.defaultFileMissing', TestClass::DEFAULT)); } /** diff --git a/tests/cases/Misc/TestContext.php b/tests/cases/Misc/TestContext.php index 4f9b3300..63bf953e 100644 --- a/tests/cases/Misc/TestContext.php +++ b/tests/cases/Misc/TestContext.php @@ -4,12 +4,12 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Misc; use JKingWeb\Arsse\Misc\Context; /** @covers \JKingWeb\Arsse\Misc\Context */ -class TestContext extends Test\AbstractTest { +class TestContext extends \JKingWeb\Arsse\Test\AbstractTest { public function testVerifyInitialState() { $c = new Context; foreach ((new \ReflectionObject($c))->getMethods(\ReflectionMethod::IS_PUBLIC) as $m) { diff --git a/tests/cases/Misc/TestValueInfo.php b/tests/cases/Misc/TestValueInfo.php index 039a21e9..87c6f018 100644 --- a/tests/cases/Misc/TestValueInfo.php +++ b/tests/cases/Misc/TestValueInfo.php @@ -4,13 +4,15 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Misc; +use JKingWeb\Arsse\ExceptionType; use JKingWeb\Arsse\Misc\ValueInfo as I; use JKingWeb\Arsse\Test\Misc\StrClass; +use JKingWeb\Arsse\Test\Result; /** @covers \JKingWeb\Arsse\Misc\ValueInfo */ -class TestValueInfo extends Test\AbstractTest { +class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest { public function setUp() { $this->clearData(); } @@ -398,7 +400,7 @@ class TestValueInfo extends Test\AbstractTest { [1e-6, [null,true], [true, false], [0, false], [1e-6, true], ["0.000001", true], [[1e-6], false]], [[1,2,3], [null,true], [true, false], [0, false], [0.0, false], ["", false], [[1,2,3], true] ], [['a'=>1,'b'=>2], [null,true], [true, false], [0, false], [0.0, false], ["", false], [['a'=>1,'b'=>2], true] ], - [new Test\Result([['a'=>1,'b'=>2]]), [null,true], [true, false], [0, false], [0.0, false], ["", false], [[['a'=>1,'b'=>2]], true] ], + [new Result([['a'=>1,'b'=>2]]), [null,true], [true, false], [0, false], [0.0, false], ["", false], [[['a'=>1,'b'=>2]], true] ], ]; $params = [ [I::T_MIXED, "Mixed" ], @@ -496,8 +498,8 @@ class TestValueInfo extends Test\AbstractTest { } // Array-mode tests $tests = [ - [I::T_INT | I::M_DROP, new Test\Result([1, 2, 2.2, 3]), [1,2,null,3] ], - [I::T_INT, new Test\Result([1, 2, 2.2, 3]), [1,2,2,3] ], + [I::T_INT | I::M_DROP, new Result([1, 2, 2.2, 3]), [1,2,null,3] ], + [I::T_INT, new Result([1, 2, 2.2, 3]), [1,2,2,3] ], [I::T_STRING | I::M_STRICT, "Bare string", ["Bare string"]], ]; foreach ($tests as $index => $test) { diff --git a/tests/cases/REST/NextCloudNews/TestNCNV1_2.php b/tests/cases/REST/NextCloudNews/TestV1_2.php similarity index 99% rename from tests/cases/REST/NextCloudNews/TestNCNV1_2.php rename to tests/cases/REST/NextCloudNews/TestV1_2.php index 6b3d2090..17c4679d 100644 --- a/tests/cases/REST/NextCloudNews/TestNCNV1_2.php +++ b/tests/cases/REST/NextCloudNews/TestV1_2.php @@ -4,8 +4,13 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\REST\NextCloudNews; +use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Conf; +use JKingWeb\Arsse\User; +use JKingWeb\Arsse\Database; +use JKingWeb\Arsse\Service; use JKingWeb\Arsse\REST\Request; use JKingWeb\Arsse\REST\Response; use JKingWeb\Arsse\Test\Result; @@ -13,10 +18,11 @@ use JKingWeb\Arsse\Misc\Date; use JKingWeb\Arsse\Misc\Context; use JKingWeb\Arsse\Db\ExceptionInput; use JKingWeb\Arsse\Db\Transaction; +use JKingWeb\Arsse\REST\NextCloudNews\V1_2; use Phake; /** @covers \JKingWeb\Arsse\REST\NextCloudNews\V1_2 */ -class TestNCNV1_2 extends Test\AbstractTest { +class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest { protected $h; protected $feeds = [ // expected sample output of a feed list from the database, and the resultant expected transformation by the REST handler 'db' => [ @@ -304,7 +310,7 @@ class TestNCNV1_2 extends Test\AbstractTest { // create a mock database interface Arsse::$db = Phake::mock(Database::class); Phake::when(Arsse::$db)->begin->thenReturn(Phake::mock(Transaction::class)); - $this->h = new REST\NextCloudNews\V1_2(); + $this->h = new V1_2(); } public function tearDown() { @@ -318,7 +324,7 @@ class TestNCNV1_2 extends Test\AbstractTest { public function testSendAuthenticationChallenge() { Phake::when(Arsse::$user)->authHTTP->thenReturn(false); - $exp = new Response(401, "", "", ['WWW-Authenticate: Basic realm="'.REST\NextCloudNews\V1_2::REALM.'"']); + $exp = new Response(401, "", "", ['WWW-Authenticate: Basic realm="'.V1_2::REALM.'"']); $this->assertResponse($exp, $this->h->dispatch(new Request("GET", "/"))); } @@ -496,7 +502,7 @@ class TestNCNV1_2 extends Test\AbstractTest { public function testRetrieveServerVersion() { $exp = new Response(200, [ - 'version' => REST\NextCloudNews\V1_2::VERSION, + 'version' => V1_2::VERSION, 'arsse_version' => Arsse::VERSION, ]); $this->assertResponse($exp, $this->h->dispatch(new Request("GET", "/version"))); @@ -867,7 +873,7 @@ class TestNCNV1_2 extends Test\AbstractTest { Phake::when(Arsse::$db)->metaGet("service_last_checkin")->thenReturn(Date::transform($valid, "sql"))->thenReturn(Date::transform($invalid, "sql")); Phake::when(Arsse::$db)->driverCharsetAcceptable->thenReturn(true)->thenReturn(false); $arr1 = $arr2 = [ - 'version' => REST\NextCloudNews\V1_2::VERSION, + 'version' => V1_2::VERSION, 'arsse_version' => Arsse::VERSION, 'warnings' => [ 'improperlyConfiguredCron' => false, diff --git a/tests/cases/REST/NextCloudNews/TestNCNVersionDiscovery.php b/tests/cases/REST/NextCloudNews/TestVersions.php similarity index 85% rename from tests/cases/REST/NextCloudNews/TestNCNVersionDiscovery.php rename to tests/cases/REST/NextCloudNews/TestVersions.php index 30749176..3081d57a 100644 --- a/tests/cases/REST/NextCloudNews/TestNCNVersionDiscovery.php +++ b/tests/cases/REST/NextCloudNews/TestVersions.php @@ -4,20 +4,21 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\REST\NextCloudNews; +use JKingWeb\Arsse\REST\NextCloudNews\Versions; use JKingWeb\Arsse\REST\Request; use JKingWeb\Arsse\REST\Response; /** @covers \JKingWeb\Arsse\REST\NextCloudNews\Versions */ -class TestNCNVersionDiscovery extends Test\AbstractTest { +class TestVersions extends \JKingWeb\Arsse\Test\AbstractTest { public function setUp() { $this->clearData(); } public function testFetchVersionList() { $exp = new Response(200, ['apiLevels' => ['v1-2']]); - $h = new REST\NextCloudNews\Versions(); + $h = new Versions; $req = new Request("GET", "/"); $res = $h->dispatch($req); $this->assertEquals($exp, $res); @@ -31,7 +32,7 @@ class TestNCNVersionDiscovery extends Test\AbstractTest { public function testRespondToOptionsRequest() { $exp = new Response(204, "", "", ["Allow: HEAD,GET"]); - $h = new REST\NextCloudNews\Versions(); + $h = new Versions; $req = new Request("OPTIONS", "/"); $res = $h->dispatch($req); $this->assertEquals($exp, $res); @@ -39,7 +40,7 @@ class TestNCNVersionDiscovery extends Test\AbstractTest { public function testUseIncorrectMethod() { $exp = new Response(405, "", "", ["Allow: HEAD,GET"]); - $h = new REST\NextCloudNews\Versions(); + $h = new Versions; $req = new Request("POST", "/"); $res = $h->dispatch($req); $this->assertEquals($exp, $res); @@ -47,7 +48,7 @@ class TestNCNVersionDiscovery extends Test\AbstractTest { public function testUseIncorrectPath() { $exp = new Response(404); - $h = new REST\NextCloudNews\Versions(); + $h = new Versions; $req = new Request("GET", "/ook"); $res = $h->dispatch($req); $this->assertEquals($exp, $res); diff --git a/tests/cases/REST/TinyTinyRSS/TestTinyTinyAPI.php b/tests/cases/REST/TinyTinyRSS/TestAPI.php similarity index 99% rename from tests/cases/REST/TinyTinyRSS/TestTinyTinyAPI.php rename to tests/cases/REST/TinyTinyRSS/TestAPI.php index 14f53645..98585081 100644 --- a/tests/cases/REST/TinyTinyRSS/TestTinyTinyAPI.php +++ b/tests/cases/REST/TinyTinyRSS/TestAPI.php @@ -4,8 +4,13 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\REST\TinyTinyRSS; +use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Conf; +use JKingWeb\Arsse\User; +use JKingWeb\Arsse\Database; +use JKingWeb\Arsse\Service; use JKingWeb\Arsse\REST\Request; use JKingWeb\Arsse\REST\Response; use JKingWeb\Arsse\Test\Result; @@ -18,7 +23,7 @@ use Phake; /** @covers \JKingWeb\Arsse\REST\TinyTinyRSS\API * @covers \JKingWeb\Arsse\REST\TinyTinyRSS\Exception */ -class TestTinyTinyAPI extends Test\AbstractTest { +class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest { protected $h; protected $folders = [ ['id' => 5, 'parent' => 3, 'children' => 0, 'feeds' => 1, 'name' => "Local"], @@ -161,7 +166,7 @@ LONG_STRING; 'expires' => "2112-12-21 21:12:00", 'user' => Arsse::$user->id, ]); - $this->h = new REST\TinyTinyRSS\API(); + $this->h = new API(); } public function tearDown() { diff --git a/tests/cases/REST/TinyTinyRSS/TestTinyTinyIcon.php b/tests/cases/REST/TinyTinyRSS/TestIcon.php similarity index 88% rename from tests/cases/REST/TinyTinyRSS/TestTinyTinyIcon.php rename to tests/cases/REST/TinyTinyRSS/TestIcon.php index 1b439b30..64f33588 100644 --- a/tests/cases/REST/TinyTinyRSS/TestTinyTinyIcon.php +++ b/tests/cases/REST/TinyTinyRSS/TestIcon.php @@ -4,14 +4,19 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\REST\TinyTinyRSS; +use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Conf; +use JKingWeb\Arsse\User; +use JKingWeb\Arsse\Database; +use JKingWeb\Arsse\REST\TinyTinyRSS\Icon; use JKingWeb\Arsse\REST\Request; use JKingWeb\Arsse\REST\Response; use Phake; /** @covers \JKingWeb\Arsse\REST\TinyTinyRSS\Icon */ -class TestTinyTinyIcon extends Test\AbstractTest { +class TestIcon extends \JKingWeb\Arsse\Test\AbstractTest { protected $h; public function setUp() { @@ -20,7 +25,7 @@ class TestTinyTinyIcon extends Test\AbstractTest { // create a mock user manager // create a mock database interface Arsse::$db = Phake::mock(Database::class); - $this->h = new REST\TinyTinyRSS\Icon(); + $this->h = new Icon(); } public function tearDown() { diff --git a/tests/cases/Service/TestService.php b/tests/cases/Service/TestService.php index 76604dfd..1ec4a3d2 100644 --- a/tests/cases/Service/TestService.php +++ b/tests/cases/Service/TestService.php @@ -4,13 +4,17 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\Service; +use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Conf; +use JKingWeb\Arsse\Database; +use JKingWeb\Arsse\Service; use JKingWeb\Arsse\Misc\Date; use Phake; /** @covers \JKingWeb\Arsse\Service */ -class TestService extends Test\AbstractTest { +class TestService extends \JKingWeb\Arsse\Test\AbstractTest { protected $srv; public function setUp() { diff --git a/tests/cases/User/TestAuthorization.php b/tests/cases/User/TestAuthorization.php index a20819d2..5692f019 100644 --- a/tests/cases/User/TestAuthorization.php +++ b/tests/cases/User/TestAuthorization.php @@ -4,42 +4,47 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\User; + +use JKingWeb\Arsse\Arsse; +use JKingWeb\Arsse\Conf; +use JKingWeb\Arsse\User; +use JKingWeb\Arsse\User\Driver; use Phake; /** @covers \JKingWeb\Arsse\User */ -class TestAuthorization extends Test\AbstractTest { +class TestAuthorization extends \JKingWeb\Arsse\Test\AbstractTest { const USERS = [ - 'user@example.com' => User\Driver::RIGHTS_NONE, - 'user@example.org' => User\Driver::RIGHTS_NONE, - 'dman@example.com' => User\Driver::RIGHTS_DOMAIN_MANAGER, - 'dman@example.org' => User\Driver::RIGHTS_DOMAIN_MANAGER, - 'dadm@example.com' => User\Driver::RIGHTS_DOMAIN_ADMIN, - 'dadm@example.org' => User\Driver::RIGHTS_DOMAIN_ADMIN, - 'gman@example.com' => User\Driver::RIGHTS_GLOBAL_MANAGER, - 'gman@example.org' => User\Driver::RIGHTS_GLOBAL_MANAGER, - 'gadm@example.com' => User\Driver::RIGHTS_GLOBAL_ADMIN, - 'gadm@example.org' => User\Driver::RIGHTS_GLOBAL_ADMIN, + 'user@example.com' => Driver::RIGHTS_NONE, + 'user@example.org' => Driver::RIGHTS_NONE, + 'dman@example.com' => Driver::RIGHTS_DOMAIN_MANAGER, + 'dman@example.org' => Driver::RIGHTS_DOMAIN_MANAGER, + 'dadm@example.com' => Driver::RIGHTS_DOMAIN_ADMIN, + 'dadm@example.org' => Driver::RIGHTS_DOMAIN_ADMIN, + 'gman@example.com' => Driver::RIGHTS_GLOBAL_MANAGER, + 'gman@example.org' => Driver::RIGHTS_GLOBAL_MANAGER, + 'gadm@example.com' => Driver::RIGHTS_GLOBAL_ADMIN, + 'gadm@example.org' => Driver::RIGHTS_GLOBAL_ADMIN, // invalid rights levels - 'bad1@example.com' => User\Driver::RIGHTS_NONE+1, - 'bad1@example.org' => User\Driver::RIGHTS_NONE+1, - 'bad2@example.com' => User\Driver::RIGHTS_DOMAIN_MANAGER+1, - 'bad2@example.org' => User\Driver::RIGHTS_DOMAIN_MANAGER+1, - 'bad3@example.com' => User\Driver::RIGHTS_DOMAIN_ADMIN+1, - 'bad3@example.org' => User\Driver::RIGHTS_DOMAIN_ADMIN+1, - 'bad4@example.com' => User\Driver::RIGHTS_GLOBAL_MANAGER+1, - 'bad4@example.org' => User\Driver::RIGHTS_GLOBAL_MANAGER+1, - 'bad5@example.com' => User\Driver::RIGHTS_GLOBAL_ADMIN+1, - 'bad5@example.org' => User\Driver::RIGHTS_GLOBAL_ADMIN+1, + 'bad1@example.com' => Driver::RIGHTS_NONE+1, + 'bad1@example.org' => Driver::RIGHTS_NONE+1, + 'bad2@example.com' => Driver::RIGHTS_DOMAIN_MANAGER+1, + 'bad2@example.org' => Driver::RIGHTS_DOMAIN_MANAGER+1, + 'bad3@example.com' => Driver::RIGHTS_DOMAIN_ADMIN+1, + 'bad3@example.org' => Driver::RIGHTS_DOMAIN_ADMIN+1, + 'bad4@example.com' => Driver::RIGHTS_GLOBAL_MANAGER+1, + 'bad4@example.org' => Driver::RIGHTS_GLOBAL_MANAGER+1, + 'bad5@example.com' => Driver::RIGHTS_GLOBAL_ADMIN+1, + 'bad5@example.org' => Driver::RIGHTS_GLOBAL_ADMIN+1, ]; const LEVELS = [ - User\Driver::RIGHTS_NONE, - User\Driver::RIGHTS_DOMAIN_MANAGER, - User\Driver::RIGHTS_DOMAIN_ADMIN, - User\Driver::RIGHTS_GLOBAL_MANAGER, - User\Driver::RIGHTS_GLOBAL_ADMIN, + Driver::RIGHTS_NONE, + Driver::RIGHTS_DOMAIN_MANAGER, + Driver::RIGHTS_DOMAIN_ADMIN, + Driver::RIGHTS_GLOBAL_MANAGER, + Driver::RIGHTS_GLOBAL_ADMIN, ]; const DOMAINS = [ '@example.com', @@ -49,7 +54,7 @@ class TestAuthorization extends Test\AbstractTest { protected $data; - public function setUp(string $drv = Test\User\DriverInternalMock::class, string $db = null) { + public function setUp(string $drv = \JkingWeb\Arsse\Test\User\DriverInternalMock::class, string $db = null) { $this->clearData(); $conf = new Conf(); $conf->userDriver = $drv; @@ -91,7 +96,7 @@ class TestAuthorization extends Test\AbstractTest { public function testRegularUserLogic() { foreach (self::USERS as $actor => $rights) { - if ($rights != User\Driver::RIGHTS_NONE) { + if ($rights != Driver::RIGHTS_NONE) { continue; } Arsse::$user->auth($actor, ""); @@ -118,7 +123,7 @@ class TestAuthorization extends Test\AbstractTest { public function testDomainManagerLogic() { foreach (self::USERS as $actor => $actorRights) { - if ($actorRights != User\Driver::RIGHTS_DOMAIN_MANAGER) { + if ($actorRights != Driver::RIGHTS_DOMAIN_MANAGER) { continue; } $actorDomain = substr($actor, strrpos($actor, "@")+1); @@ -139,7 +144,7 @@ class TestAuthorization extends Test\AbstractTest { } // and they should only be able to set their own rights to regular user foreach (self::LEVELS as $level) { - if ($actor==$affected && in_array($level, [User\Driver::RIGHTS_NONE, User\Driver::RIGHTS_DOMAIN_MANAGER])) { + if ($actor==$affected && in_array($level, [User\Driver::RIGHTS_NONE, Driver::RIGHTS_DOMAIN_MANAGER])) { $this->assertTrue(Arsse::$user->authorize($affected, "userRightsSet", $level), "User $actor acted properly for $affected settings rights level $level, but the action was denied."); } else { $this->assertFalse(Arsse::$user->authorize($affected, "userRightsSet", $level), "User $actor acted improperly for $affected settings rights level $level, but the action was allowed."); @@ -159,7 +164,7 @@ class TestAuthorization extends Test\AbstractTest { public function testDomainAdministratorLogic() { foreach (self::USERS as $actor => $actorRights) { - if ($actorRights != User\Driver::RIGHTS_DOMAIN_ADMIN) { + if ($actorRights != Driver::RIGHTS_DOMAIN_ADMIN) { continue; } $actorDomain = substr($actor, strrpos($actor, "@")+1); @@ -201,7 +206,7 @@ class TestAuthorization extends Test\AbstractTest { public function testGlobalManagerLogic() { foreach (self::USERS as $actor => $actorRights) { - if ($actorRights != User\Driver::RIGHTS_GLOBAL_MANAGER) { + if ($actorRights != Driver::RIGHTS_GLOBAL_MANAGER) { continue; } $actorDomain = substr($actor, strrpos($actor, "@")+1); @@ -218,7 +223,7 @@ class TestAuthorization extends Test\AbstractTest { } // and they should only be able to set their own rights to regular user foreach (self::LEVELS as $level) { - if ($actor==$affected && in_array($level, [User\Driver::RIGHTS_NONE, User\Driver::RIGHTS_GLOBAL_MANAGER])) { + if ($actor==$affected && in_array($level, [User\Driver::RIGHTS_NONE, Driver::RIGHTS_GLOBAL_MANAGER])) { $this->assertTrue(Arsse::$user->authorize($affected, "userRightsSet", $level), "User $actor acted properly for $affected settings rights level $level, but the action was denied."); } else { $this->assertFalse(Arsse::$user->authorize($affected, "userRightsSet", $level), "User $actor acted improperly for $affected settings rights level $level, but the action was allowed."); @@ -234,7 +239,7 @@ class TestAuthorization extends Test\AbstractTest { public function testGlobalAdministratorLogic() { foreach (self::USERS as $actor => $actorRights) { - if ($actorRights != User\Driver::RIGHTS_GLOBAL_ADMIN) { + if ($actorRights != Driver::RIGHTS_GLOBAL_ADMIN) { continue; } Arsse::$user->auth($actor, ""); @@ -302,7 +307,7 @@ class TestAuthorization extends Test\AbstractTest { public function testExternalExceptionLogic() { // set up the test for an external driver - $this->setUp(Test\User\DriverExternalMock::class, Test\User\Database::class); + $this->setUp(\JKingWeb\Arsse\Test\User\DriverExternalMock::class, \JKingWeb\Arsse\Test\User\Database::class); // run the previous test with the external driver set up $this->testInternalExceptionLogic(); } @@ -318,7 +323,7 @@ class TestAuthorization extends Test\AbstractTest { } try { call_user_func_array(array(Arsse::$user, $func), $args); - } catch (User\ExceptionAuthz $e) { + } catch (\JKingWeb\Arsse\User\ExceptionAuthz $e) { $err[] = $func; } } diff --git a/tests/cases/User/TestUserMockExternal.php b/tests/cases/User/TestMockExternal.php similarity index 54% rename from tests/cases/User/TestUserMockExternal.php rename to tests/cases/User/TestMockExternal.php index 3f418f3e..928edc7c 100644 --- a/tests/cases/User/TestUserMockExternal.php +++ b/tests/cases/User/TestMockExternal.php @@ -4,14 +4,14 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\User; /** @covers \JKingWeb\Arsse\User */ -class TestUserMockExternal extends Test\AbstractTest { - use Test\User\CommonTests; +class TestMockExternal extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\User\CommonTests; const USER1 = "john.doe@example.com"; const USER2 = "jane.doe@example.com"; - public $drv = Test\User\DriverExternalMock::class; + public $drv = \JKingWeb\Arsse\Test\User\DriverExternalMock::class; } diff --git a/tests/cases/User/TestUserMockInternal.php b/tests/cases/User/TestMockInternal.php similarity index 57% rename from tests/cases/User/TestUserMockInternal.php rename to tests/cases/User/TestMockInternal.php index 5386853a..aa765059 100644 --- a/tests/cases/User/TestUserMockInternal.php +++ b/tests/cases/User/TestMockInternal.php @@ -4,16 +4,18 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\User; + +use JKingWeb\Arsse\Arsse; /** @covers \JKingWeb\Arsse\User */ -class TestUserMockInternal extends Test\AbstractTest { - use Test\User\CommonTests; +class TestMockInternal extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\User\CommonTests; const USER1 = "john.doe@example.com"; const USER2 = "jane.doe@example.com"; - public $drv = Test\User\DriverInternalMock::class; + public $drv = \JKingWeb\Arsse\Test\User\DriverInternalMock::class; public function setUpSeries() { Arsse::$db = null; diff --git a/tests/cases/User/TestUserInternalDriver.php b/tests/cases/User/Testnternal.php similarity index 64% rename from tests/cases/User/TestUserInternalDriver.php rename to tests/cases/User/Testnternal.php index cfd89788..1bbf2560 100644 --- a/tests/cases/User/TestUserInternalDriver.php +++ b/tests/cases/User/Testnternal.php @@ -4,17 +4,17 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace JKingWeb\Arsse; +namespace JKingWeb\Arsse\TestCase\User; /** * @covers \JKingWeb\Arsse\User * @covers \JKingWeb\Arsse\User\Internal\Driver * @covers \JKingWeb\Arsse\User\Internal\InternalFunctions */ -class TestUserInternalDriver extends Test\AbstractTest { - use Test\User\CommonTests; +class TestInternal extends \JKingWeb\Arsse\Test\AbstractTest { + use \JKingWeb\Arsse\Test\User\CommonTests; const USER1 = "john.doe@example.com"; const USER2 = "jane.doe@example.com"; - public $drv = User\Internal\Driver::class; + public $drv = \JKingWeb\Arsse\User\Internal\Driver::class; } diff --git a/tests/lib/Database/Setup.php b/tests/lib/Database/Setup.php index 41428187..42abc756 100644 --- a/tests/lib/Database/Setup.php +++ b/tests/lib/Database/Setup.php @@ -89,7 +89,7 @@ trait Setup { foreach ($info['rows'] as $index => $row) { $this->assertCount(sizeof($cols), $row, "The number of values for array index $index does not match the number of fields"); $row = array_combine($cols, $row); - foreach($data as $index => $test) { + foreach ($data as $index => $test) { foreach ($test as $col => $value) { switch ($types[$col]) { case "datetime": @@ -106,7 +106,7 @@ trait Setup { break; } } - if($row===$test) { + if ($row===$test) { $data[$index] = $test; break; } diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 37e5bbef..12cf9bcf 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -21,9 +21,9 @@ cases/Exception/TestException.php - cases/Lang/TestLang.php - cases/Lang/TestLangComplex.php - cases/Lang/TestLangErrors.php + cases/Lang/TestBasic.php + cases/Lang/TestComplex.php + cases/Lang/TestErrors.php cases/Conf/TestConf.php @@ -33,24 +33,24 @@ cases/Misc/TestContext.php - cases/User/TestUserMockInternal.php - cases/User/TestUserMockExternal.php - cases/User/TestUserInternalDriver.php + cases/User/TestMockInternal.php + cases/User/TestMockExternal.php + cases/User/TestInternal.php cases/User/TestAuthorization.php - cases/Feed/TestFeedFetching.php + cases/Feed/TestFetching.php cases/Feed/TestFeed.php cases/Db/TestTransaction.php cases/Db/TestResultAggregate.php cases/Db/TestResultEmpty.php - cases/Db/SQLite3/TestDbResultSQLite3.php - cases/Db/SQLite3/TestDbStatementSQLite3.php - cases/Db/SQLite3/TestDbDriverCreationSQLite3.php - cases/Db/SQLite3/TestDbDriverSQLite3.php - cases/Db/SQLite3/TestDbUpdateSQLite3.php + cases/Db/SQLite3/TestResult.php + cases/Db/SQLite3/TestStatement.php + cases/Db/SQLite3/TestCreation.php + cases/Db/SQLite3/TestDriver.php + cases/Db/SQLite3/TestUpdate.php cases/Db/SQLite3PDO/TestDbResultSQLite3PDO.php cases/Db/SQLite3PDO/TestDbStatementSQLite3PDO.php @@ -59,16 +59,16 @@ cases/Db/SQLite3PDO/TestDbUpdateSQLite3PDO.php - cases/Db/SQLite3/Database/TestDatabaseMiscellanySQLite3.php - cases/Db/SQLite3/Database/TestDatabaseMetaSQLite3.php - cases/Db/SQLite3/Database/TestDatabaseUserSQLite3.php - cases/Db/SQLite3/Database/TestDatabaseSessionSQLite3.php - cases/Db/SQLite3/Database/TestDatabaseFolderSQLite3.php - cases/Db/SQLite3/Database/TestDatabaseFeedSQLite3.php - cases/Db/SQLite3/Database/TestDatabaseSubscriptionSQLite3.php - cases/Db/SQLite3/Database/TestDatabaseArticleSQLite3.php - cases/Db/SQLite3/Database/TestDatabaseLabelSQLite3.php - cases/Db/SQLite3/Database/TestDatabaseCleanupSQLite3.php + cases/Db/SQLite3/Database/TestMiscellany.php + cases/Db/SQLite3/Database/TestMeta.php + cases/Db/SQLite3/Database/TestUser.php + cases/Db/SQLite3/Database/TestSession.php + cases/Db/SQLite3/Database/TestFolder.php + cases/Db/SQLite3/Database/TestFeed.php + cases/Db/SQLite3/Database/TestSubscription.php + cases/Db/SQLite3/Database/TestArticle.php + cases/Db/SQLite3/Database/TestLabel.php + cases/Db/SQLite3/Database/TestCleanup.php cases/Db/SQLite3PDO/Database/TestDatabaseMiscellanySQLite3PDO.php cases/Db/SQLite3PDO/Database/TestDatabaseUserSQLite3PDO.php @@ -82,12 +82,12 @@ - cases/REST/NextCloudNews/TestNCNVersionDiscovery.php - cases/REST/NextCloudNews/TestNCNV1_2.php + cases/REST/NextCloudNews/TestVersions.php + cases/REST/NextCloudNews/TestV1_2.php - cases/REST/TinyTinyRSS/TestTinyTinyAPI.php - cases/REST/TinyTinyRSS/TestTinyTinyIcon.php + cases/REST/TinyTinyRSS/TestAPI.php + cases/REST/TinyTinyRSS/TestIcon.php