From 81dd63c152d29978122a6342a900b3e509bd8e47 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 27 Jan 2019 20:28:31 +0100 Subject: [PATCH] Optimized Actions, Tests and renamed LIST to THREAD out of php incompatibility reasons --- .../symfony/src/DBAL/Types/ActionType.php | 4 +-- .../Create/AbstractCreateAction.php | 11 +++++++- .../Create/CreateActionInterface.php | 12 +++++++++ .../Create/CreateSourceAction.php | 4 --- .../Thread/AbstractThreadAction.php | 12 +++++++++ .../Thread/ThreadSourceAction.php | 26 +++++++++++++++++++ .../Update/AbstractUpdateAction.php | 12 +++++++++ .../Update/UpdateSourceAction.php | 16 +++++++++++- .../Domain/LayerManagement/LayerActionMap.php | 2 +- .../Action/RequestedAction.php | 2 +- .../ActionFactoryServiceTest.php | 7 +++-- .../Action/RequestedActionTest.php | 2 +- 12 files changed, 95 insertions(+), 15 deletions(-) create mode 100644 application/symfony/src/Domain/ActionManagement/Create/CreateActionInterface.php create mode 100644 application/symfony/src/Domain/ActionManagement/Thread/AbstractThreadAction.php create mode 100644 application/symfony/src/Domain/ActionManagement/Thread/ThreadSourceAction.php create mode 100644 application/symfony/src/Domain/ActionManagement/Update/AbstractUpdateAction.php diff --git a/application/symfony/src/DBAL/Types/ActionType.php b/application/symfony/src/DBAL/Types/ActionType.php index 9598413..0ac139d 100644 --- a/application/symfony/src/DBAL/Types/ActionType.php +++ b/application/symfony/src/DBAL/Types/ActionType.php @@ -11,13 +11,13 @@ use App\DBAL\Types\Meta\Right\CRUDType; */ final class ActionType extends CRUDType { - const LIST = 'list'; + const THREAD = 'thread'; protected static $choices = [ parent::CREATE => 'create', parent::READ => 'read', parent::UPDATE => 'update', parent::DELETE => 'delete', - self::LIST => 'list', + self::THREAD => 'thread', ]; } diff --git a/application/symfony/src/Domain/ActionManagement/Create/AbstractCreateAction.php b/application/symfony/src/Domain/ActionManagement/Create/AbstractCreateAction.php index a17e627..f0f9cb4 100644 --- a/application/symfony/src/Domain/ActionManagement/Create/AbstractCreateAction.php +++ b/application/symfony/src/Domain/ActionManagement/Create/AbstractCreateAction.php @@ -7,6 +7,15 @@ use App\Domain\ActionManagement\AbstractAction; /** * @author kevinfrantz */ -abstract class AbstractCreateAction extends AbstractAction +abstract class AbstractCreateAction extends AbstractAction implements CreateActionInterface { + /** + * {@inheritdoc} + * + * @see \App\Domain\ActionManagement\AbstractAction::isSecure() + */ + protected function isSecure(): bool + { + return $this->actionService->isRequestedActionSecure(); + } } diff --git a/application/symfony/src/Domain/ActionManagement/Create/CreateActionInterface.php b/application/symfony/src/Domain/ActionManagement/Create/CreateActionInterface.php new file mode 100644 index 0000000..d912d1f --- /dev/null +++ b/application/symfony/src/Domain/ActionManagement/Create/CreateActionInterface.php @@ -0,0 +1,12 @@ + CRUDType::READ, + ActionType::THREAD => CRUDType::READ, ]; /** diff --git a/application/symfony/tests/Unit/Domain/ActionManagement/ActionFactoryServiceTest.php b/application/symfony/tests/Unit/Domain/ActionManagement/ActionFactoryServiceTest.php index 620d32f..a2dc9d0 100644 --- a/application/symfony/tests/Unit/Domain/ActionManagement/ActionFactoryServiceTest.php +++ b/application/symfony/tests/Unit/Domain/ActionManagement/ActionFactoryServiceTest.php @@ -2,16 +2,15 @@ namespace tests\Unit\Domain\SecureCRUDManagement\Factory; -use App\DBAL\Types\Meta\Right\LayerType; use PHPUnit\Framework\TestCase; use App\Domain\ActionManagement\ActionFactoryServiceInterface; use App\Domain\ActionManagement\ActionFactoryService; use App\Domain\ActionManagement\ActionServiceInterface; -use App\DBAL\Types\ActionType; use App\Domain\ActionManagement\ActionInterface; use App\Domain\RequestManagement\Action\RequestedActionInterface; use App\Domain\RequestManagement\Action\RequestedAction; use App\Domain\RequestManagement\Right\RequestedRight; +use App\Domain\LayerManagement\LayerActionMap; /** * @author kevinfrantz @@ -44,8 +43,8 @@ class ActionFactoryServiceTest extends TestCase public function testCreate(): void { - foreach (ActionType::getChoices() as $action) { - foreach (LayerType::getChoices() as $layer) { + foreach (LayerActionMap::LAYER_ACTION_MAP as $layer => $actions) { + foreach ($actions as $action) { $this->requestedAction->setLayer($layer); $this->requestedAction->setActionType($action); $result = $this->actionFactoryService->create(); diff --git a/application/symfony/tests/Unit/Domain/RequestManagement/Action/RequestedActionTest.php b/application/symfony/tests/Unit/Domain/RequestManagement/Action/RequestedActionTest.php index a4452d4..e06ed55 100644 --- a/application/symfony/tests/Unit/Domain/RequestManagement/Action/RequestedActionTest.php +++ b/application/symfony/tests/Unit/Domain/RequestManagement/Action/RequestedActionTest.php @@ -41,7 +41,7 @@ class RequestedActionTest extends TestCase public function testList(): void { - $list = ActionType::LIST; + $list = ActionType::THREAD; $this->action->setActionType($list); $this->assertEquals($list, $this->action->getActionType()); $this->assertEquals(CRUDType::READ, $this->requestedRight->getCrud());