From 0796549cbad8afd9f5356d9df60a0840683edf64 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 28 Sep 2021 18:28:42 +0200 Subject: [PATCH] rename module constants and fix some unit test bugs --- Admin/Routes/Web/Api.php | 10 +++++----- Admin/Routes/Web/Backend.php | 10 +++++----- Controller/ApiController.php | 6 +++--- Controller/BackendController.php | 8 ++++---- Controller/Controller.php | 8 ++++---- tests/Admin/AdminTest.php | 2 +- tests/Controller/test/path/created.md | 1 - tests/Controller/test/path/testFile1.txt | 1 + tests/Controller/test/path/testFile2.txt | 1 + 9 files changed, 24 insertions(+), 23 deletions(-) delete mode 100644 tests/Controller/test/path/created.md create mode 100644 tests/Controller/test/path/testFile1.txt create mode 100644 tests/Controller/test/path/testFile2.txt diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php index 80554ce..5024cf9 100755 --- a/Admin/Routes/Web/Api.php +++ b/Admin/Routes/Web/Api.php @@ -23,7 +23,7 @@ return [ 'dest' => '\Modules\Media\Controller\ApiController:apiMediaUpload', 'verb' => RouteVerb::PUT, 'permission' => [ - 'module' => ApiController::MODULE_NAME, + 'module' => ApiController::NAME, 'type' => PermissionType::CREATE, 'state' => PermissionState::MEDIA, ], @@ -32,7 +32,7 @@ return [ 'dest' => '\Modules\Media\Controller\ApiController:apiMediaUpdate', 'verb' => RouteVerb::SET, 'permission' => [ - 'module' => ApiController::MODULE_NAME, + 'module' => ApiController::NAME, 'type' => PermissionType::CREATE, 'state' => PermissionState::MEDIA, ], @@ -43,7 +43,7 @@ return [ 'dest' => '\Modules\Media\Controller\ApiController:apiMediaCreate', 'verb' => RouteVerb::PUT, 'permission' => [ - 'module' => ApiController::MODULE_NAME, + 'module' => ApiController::NAME, 'type' => PermissionType::CREATE, 'state' => PermissionState::MEDIA, ], @@ -54,7 +54,7 @@ return [ 'dest' => '\Modules\Media\Controller\ApiController:apiMediaExport', 'verb' => RouteVerb::GET, 'permission' => [ - 'module' => ApiController::MODULE_NAME, + 'module' => ApiController::NAME, 'type' => PermissionType::READ, 'state' => PermissionState::MEDIA, ], @@ -65,7 +65,7 @@ return [ 'dest' => '\Modules\Media\Controller\ApiController:apiCollectionCreate', 'verb' => RouteVerb::PUT, 'permission' => [ - 'module' => ApiController::MODULE_NAME, + 'module' => ApiController::NAME, 'type' => PermissionType::CREATE, 'state' => PermissionState::MEDIA, ], diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index 4c2bb67..0517e88 100755 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -23,7 +23,7 @@ return [ 'dest' => '\Modules\Media\Controller\BackendController:viewMediaList', 'verb' => RouteVerb::GET, 'permission' => [ - 'module' => BackendController::MODULE_NAME, + 'module' => BackendController::NAME, 'type' => PermissionType::READ, 'state' => PermissionState::MEDIA, ], @@ -34,7 +34,7 @@ return [ 'dest' => '\Modules\Media\Controller\BackendController:viewMediaUpload', 'verb' => RouteVerb::GET, 'permission' => [ - 'module' => BackendController::MODULE_NAME, + 'module' => BackendController::NAME, 'type' => PermissionType::CREATE, 'state' => PermissionState::MEDIA, ], @@ -45,7 +45,7 @@ return [ 'dest' => '\Modules\Media\Controller\BackendController:viewMediaFileCreate', 'verb' => RouteVerb::GET, 'permission' => [ - 'module' => BackendController::MODULE_NAME, + 'module' => BackendController::NAME, 'type' => PermissionType::CREATE, 'state' => PermissionState::MEDIA, ], @@ -56,7 +56,7 @@ return [ 'dest' => '\Modules\Media\Controller\BackendController:viewMediaCollectionCreate', 'verb' => RouteVerb::GET, 'permission' => [ - 'module' => BackendController::MODULE_NAME, + 'module' => BackendController::NAME, 'type' => PermissionType::CREATE, 'state' => PermissionState::MEDIA, ], @@ -67,7 +67,7 @@ return [ 'dest' => '\Modules\Media\Controller\BackendController:viewMediaSingle', 'verb' => RouteVerb::GET, 'permission' => [ - 'module' => BackendController::MODULE_NAME, + 'module' => BackendController::NAME, 'type' => PermissionType::READ, 'state' => PermissionState::MEDIA, ], diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 1004b20..09eb18f 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -244,8 +244,8 @@ final class ApiController extends Controller $account, $this->app->orgId, $this->app->appName, - self::MODULE_NAME, - self::MODULE_NAME, + self::NAME, + self::NAME, PermissionState::MEDIA, $created->getId(), null, @@ -494,7 +494,7 @@ final class ApiController extends Controller { if (empty($media) || !$this->app->accountManager->get($account)->hasPermission( - PermissionType::CREATE, $this->app->orgId, null, self::MODULE_NAME, PermissionState::COLLECTION, null) + PermissionType::CREATE, $this->app->orgId, null, self::NAME, PermissionState::COLLECTION, null) ) { return new NullCollection(); } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 589c248..178efde 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -44,7 +44,7 @@ final class BackendController extends Controller * @var string * @since 1.0.0 */ - public const MODULE_PATH = __DIR__; + public const PATH = __DIR__; /** * Module version. @@ -52,7 +52,7 @@ final class BackendController extends Controller * @var string * @since 1.0.0 */ - public const MODULE_VERSION = '1.0.0'; + public const VERSION = '1.0.0'; /** * Module name. @@ -60,7 +60,7 @@ final class BackendController extends Controller * @var string * @since 1.0.0 */ - public const MODULE_NAME = 'Media'; + public const NAME = 'Media'; /** * Module id. @@ -68,7 +68,7 @@ final class BackendController extends Controller * @var int * @since 1.0.0 */ - public const MODULE_ID = 1000400000; + public const ID = 1000400000; /** * Providing. diff --git a/Controller/Controller.php b/Controller/Controller.php index 4d2b986..5512aca 100755 --- a/Controller/Controller.php +++ b/Controller/Controller.php @@ -40,7 +40,7 @@ class Controller extends ModuleAbstract * @var string * @since 1.0.0 */ - public const MODULE_PATH = __DIR__ . '/../'; + public const PATH = __DIR__ . '/../'; /** * Module version. @@ -48,7 +48,7 @@ class Controller extends ModuleAbstract * @var string * @since 1.0.0 */ - public const MODULE_VERSION = '1.0.0'; + public const VERSION = '1.0.0'; /** * Module name. @@ -56,7 +56,7 @@ class Controller extends ModuleAbstract * @var string * @since 1.0.0 */ - public const MODULE_NAME = 'Media'; + public const NAME = 'Media'; /** * Module id. @@ -64,7 +64,7 @@ class Controller extends ModuleAbstract * @var int * @since 1.0.0 */ - public const MODULE_ID = 1000400000; + public const ID = 1000400000; /** * Providing. diff --git a/tests/Admin/AdminTest.php b/tests/Admin/AdminTest.php index 0eb08b5..77ba859 100755 --- a/tests/Admin/AdminTest.php +++ b/tests/Admin/AdminTest.php @@ -22,7 +22,7 @@ use phpOMS\Application\ApplicationAbstract; */ class AdminTest extends \PHPUnit\Framework\TestCase { - protected const MODULE_NAME = 'Media'; + protected const NAME = 'Media'; protected const URI_LOAD = 'http://127.0.0.1/en/backend/media'; diff --git a/tests/Controller/test/path/created.md b/tests/Controller/test/path/created.md deleted file mode 100644 index 8773f39..0000000 --- a/tests/Controller/test/path/created.md +++ /dev/null @@ -1 +0,0 @@ -file content \ No newline at end of file diff --git a/tests/Controller/test/path/testFile1.txt b/tests/Controller/test/path/testFile1.txt new file mode 100644 index 0000000..8d04345 --- /dev/null +++ b/tests/Controller/test/path/testFile1.txt @@ -0,0 +1 @@ +Test Content \ No newline at end of file diff --git a/tests/Controller/test/path/testFile2.txt b/tests/Controller/test/path/testFile2.txt new file mode 100644 index 0000000..55afc44 --- /dev/null +++ b/tests/Controller/test/path/testFile2.txt @@ -0,0 +1 @@ +Media/Collection Test 2 \ No newline at end of file