From 7300f059c3fd3258b2222f09007acb4a2ea6b721 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sat, 5 Jan 2019 17:27:40 +0100 Subject: [PATCH] Updated type references --- application/config/packages/doctrine.yaml | 4 ++-- application/src/Controller/DefaultController.php | 6 +++--- .../src/DBAL/Types/Meta/Right/LayerType.php | 2 +- application/src/DataFixtures/SourceFixtures.php | 6 +++--- .../Domain/TemplateManagement/TemplateMeta.php | 4 ++-- application/src/Entity/Meta/Right.php | 12 ++++++------ .../API/ApiUrlReachableIntegrationTest.php | 2 +- .../LawManagement/LawPermissionCheckerTest.php | 12 ++++++------ .../SourceRESTReponseManagerTest.php | 6 +++--- .../Domain/RightManagement/RightCheckerTest.php | 12 ++++++------ .../SecureSourceLoaderTest.php | 8 ++++---- .../SecureSourceCheckerTest.php | 16 ++++++++-------- .../Unit/Entity/Attribut/LayerAttributTest.php | 2 +- application/tests/Unit/Entity/Meta/RightTest.php | 8 ++++---- .../Unit/Repository/RightRepositoryTest.php | 6 +++--- 15 files changed, 53 insertions(+), 53 deletions(-) diff --git a/application/config/packages/doctrine.yaml b/application/config/packages/doctrine.yaml index 3a349de..f03d87f 100644 --- a/application/config/packages/doctrine.yaml +++ b/application/config/packages/doctrine.yaml @@ -16,8 +16,8 @@ doctrine: collate: utf8mb4_unicode_ci url: '%env(resolve:DATABASE_URL)%' types: - RightType: App\DBAL\Types\RightType - LayerType: App\DBAL\Types\LayerType + CRUDType: App\DBAL\Types\Meta\Right\CRUDType + LayerType: App\DBAL\Types\Meta\Right\LayerType orm: auto_generate_proxy_classes: '%kernel.debug%' naming_strategy: doctrine.orm.naming_strategy.underscore diff --git a/application/src/Controller/DefaultController.php b/application/src/Controller/DefaultController.php index fe441ba..26e89cd 100644 --- a/application/src/Controller/DefaultController.php +++ b/application/src/Controller/DefaultController.php @@ -7,8 +7,8 @@ use Symfony\Component\HttpFoundation\Response; use App\DBAL\Types\SystemSlugType; use App\Entity\Source\AbstractSource; use App\Entity\Meta\Right; -use App\DBAL\Types\LayerType; -use App\DBAL\Types\RightType; +use App\DBAL\Types\Meta\Right\LayerType; +use App\DBAL\Types\Meta\Right\CRUDType; use Doctrine\ORM\EntityManagerInterface; use App\Entity\Source\PureSource; use App\Domain\ResponseManagement\SourceRESTResponseManager; @@ -31,7 +31,7 @@ final class DefaultController extends AbstractEntityController $requestedRight = new Right(); $requestedRight->setSource($requestedSource); $requestedRight->setLayer(LayerType::SOURCE); - $requestedRight->setType(RightType::READ); + $requestedRight->setType(CRUDType::READ); $sourceResponseManager = new SourceRESTResponseManager($this->getUser(), $entityManager, $requestedRight, $this->getViewHandler()); return $sourceResponseManager->getResponse(); diff --git a/application/src/DBAL/Types/Meta/Right/LayerType.php b/application/src/DBAL/Types/Meta/Right/LayerType.php index 911f859..972da9b 100644 --- a/application/src/DBAL/Types/Meta/Right/LayerType.php +++ b/application/src/DBAL/Types/Meta/Right/LayerType.php @@ -1,6 +1,6 @@ impressumSource); $sourceRightManager->addRight($right); $right->setLayer(LayerType::SOURCE); - $right->setType(RightType::READ); + $right->setType(CRUDType::READ); $right->setReciever($this->guestUserSource); return $right; diff --git a/application/src/Domain/TemplateManagement/TemplateMeta.php b/application/src/Domain/TemplateManagement/TemplateMeta.php index fe33fa8..262c37b 100644 --- a/application/src/Domain/TemplateManagement/TemplateMeta.php +++ b/application/src/Domain/TemplateManagement/TemplateMeta.php @@ -2,7 +2,7 @@ namespace App\Domain\TemplateManagement; -use App\DBAL\Types\TemplateType; +use App\DBAL\Types\RESTResponseType; /** * @author kevinfrantz @@ -22,7 +22,7 @@ final class TemplateMeta implements TemplateMetaInterface /** * @var string */ - private $type = TemplateType::HTML; + private $type = RESTResponseType::HTML; /** * @var string diff --git a/application/src/Entity/Meta/Right.php b/application/src/Entity/Meta/Right.php index 6514bd9..ea95cbf 100644 --- a/application/src/Entity/Meta/Right.php +++ b/application/src/Entity/Meta/Right.php @@ -6,8 +6,7 @@ use App\Entity\Attribut\TypeAttribut; use Doctrine\ORM\Mapping as ORM; use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert; use App\Entity\Attribut\LawAttribut; -use App\DBAL\Types\LayerType; -use App\DBAL\Types\RightType; +use App\DBAL\Types\Meta\Right\LayerType; use App\Entity\Attribut\GrantAttribut; use App\Logic\Operation\OperationInterface; use App\Entity\Attribut\ConditionAttribut; @@ -17,6 +16,7 @@ use App\Entity\Attribut\RelationAttribut; use App\Entity\Attribut\PriorityAttribut; use App\Entity\Source\SourceInterface; use App\Exception\NoValidChoiceException; +use App\DBAL\Types\Meta\Right\CRUDType; /** * @author kevinfrantz @@ -52,7 +52,7 @@ class Right extends AbstractMeta implements RightInterface /** * @ORM\Column(name="layer", type="LayerType", nullable=false) - * @DoctrineAssert\Enum(entity="App\DBAL\Types\LayerType") + * @DoctrineAssert\Enum(entity="App\DBAL\Types\Meta\Right\LayerType") * * @var string */ @@ -75,8 +75,8 @@ class Right extends AbstractMeta implements RightInterface protected $grant; /** - * @ORM\Column(name="type", type="RightType", nullable=false) - * @DoctrineAssert\Enum(entity="App\DBAL\Types\RightType") + * @ORM\Column(name="type", type="CRUDType", nullable=false) + * @DoctrineAssert\Enum(entity="App\DBAL\Types\Meta\Right\CRUDType") * * @var string */ @@ -99,7 +99,7 @@ class Right extends AbstractMeta implements RightInterface public function setType(string $type): void { - if (!array_key_exists($type, RightType::getChoices())) { + if (!array_key_exists($type, CRUDType::getChoices())) { throw new NoValidChoiceException(); } $this->type = $type; diff --git a/application/tests/Integration/Controller/API/ApiUrlReachableIntegrationTest.php b/application/tests/Integration/Controller/API/ApiUrlReachableIntegrationTest.php index c96e23d..f537da1 100644 --- a/application/tests/Integration/Controller/API/ApiUrlReachableIntegrationTest.php +++ b/application/tests/Integration/Controller/API/ApiUrlReachableIntegrationTest.php @@ -5,7 +5,7 @@ namespace Tests\Integration\Controller\API; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\BrowserKit\Request; use App\DBAL\Types\LanguageType; -use App\DBAL\Types\Meta\LayerType; +use App\DBAL\Types\Meta\Right\LayerType; use App\DBAL\Types\RESTResponseType; /** diff --git a/application/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php b/application/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php index 8a410ff..489ab47 100644 --- a/application/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php +++ b/application/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php @@ -7,8 +7,8 @@ use App\Domain\LawManagement\LawPermissionCheckerService; use App\Domain\LawManagement\LawPermissionCheckerServiceInterface; use App\Entity\Source\SourceInterface; use App\Entity\Meta\Right; -use App\DBAL\Types\LayerType; -use App\DBAL\Types\RightType; +use App\DBAL\Types\Meta\Right\LayerType; +use App\DBAL\Types\Meta\Right\CRUDType; use App\Entity\Meta\Law; use App\Entity\Meta\LawInterface; use App\Entity\Meta\RightInterface; @@ -87,7 +87,7 @@ class LawPermissionCheckerTest extends TestCase { $this->clientRight = new Right(); $this->clientRight->setLayer(LayerType::SOURCE); - $this->clientRight->setType(RightType::READ); + $this->clientRight->setType(CRUDType::READ); $this->clientRight->setReciever($this->clientSource); $this->clientRight->setSource($this->source); } @@ -107,7 +107,7 @@ class LawPermissionCheckerTest extends TestCase { $this->law->getRights()->add($this->getClonedClientRight()); $this->assertTrue($this->checkClientPermission()); - $this->clientRight->setType(RightType::WRITE); + $this->clientRight->setType(CRUDType::UPDATE); $this->assertFalse($this->checkClientPermission()); } @@ -142,10 +142,10 @@ class LawPermissionCheckerTest extends TestCase public function testGetRightsByType(): void { $right = $this->getClonedClientRight(); - $right->setType(RightType::WRITE); + $right->setType(CRUDType::UPDATE); $this->law->getRights()->add($right); $this->assertFalse($this->checkClientPermission()); - $right->setType(RightType::READ); + $right->setType(CRUDType::READ); $this->assertTrue($this->checkClientPermission()); } diff --git a/application/tests/Unit/Domain/ResponseManagement/SourceRESTReponseManagerTest.php b/application/tests/Unit/Domain/ResponseManagement/SourceRESTReponseManagerTest.php index fece7f2..362b10a 100644 --- a/application/tests/Unit/Domain/ResponseManagement/SourceRESTReponseManagerTest.php +++ b/application/tests/Unit/Domain/ResponseManagement/SourceRESTReponseManagerTest.php @@ -9,8 +9,8 @@ use App\Entity\Meta\Right; use FOS\RestBundle\View\ViewHandlerInterface; use App\Entity\Source\PureSource; use App\DBAL\Types\SystemSlugType; -use App\DBAL\Types\LayerType; -use App\DBAL\Types\RightType; +use App\DBAL\Types\Meta\Right\LayerType; +use App\DBAL\Types\Meta\Right\CRUDType; use App\Domain\ResponseManagement\SourceRESTResponseManager; use App\Exception\AllreadyDefinedException; @@ -67,7 +67,7 @@ class SourceRESTReponseManagerTest extends KernelTestCase $requestedRight->setSource($requestedSource); $requestedRight->setReciever(new PureSource()); $requestedRight->setLayer(LayerType::SOURCE); - $requestedRight->setType(RightType::READ); + $requestedRight->setType(CRUDType::READ); $this->expectException(AllreadyDefinedException::class); $sourceResponseManager = new SourceRESTResponseManager(null, $this->entityManager, $requestedRight, $this->viewHandler); $sourceResponseManager->getResponse(); diff --git a/application/tests/Unit/Domain/RightManagement/RightCheckerTest.php b/application/tests/Unit/Domain/RightManagement/RightCheckerTest.php index e5ea8e6..c0be286 100644 --- a/application/tests/Unit/Domain/RightManagement/RightCheckerTest.php +++ b/application/tests/Unit/Domain/RightManagement/RightCheckerTest.php @@ -6,10 +6,10 @@ use PHPUnit\Framework\TestCase; use App\Entity\Meta\RightInterface; use App\Entity\Meta\Right; use App\Entity\Source\SourceInterface; -use App\DBAL\Types\LayerType; +use App\DBAL\Types\Meta\Right\LayerType; use App\Domain\RightManagement\RightCheckerInterface; use App\Domain\RightManagement\RightChecker; -use App\DBAL\Types\RightType; +use App\DBAL\Types\Meta\Right\CRUDType; use App\Entity\Source\PureSource; class RightCheckerTest extends TestCase @@ -42,7 +42,7 @@ class RightCheckerTest extends TestCase public function setUp(): void { $this->layer = LayerType::RELATION; - $this->type = RightType::READ; + $this->type = CRUDType::READ; $this->source = new PureSource(); $this->right = new Right(); $this->right->setReciever($this->source); @@ -57,7 +57,7 @@ class RightCheckerTest extends TestCase $this->assertTrue($granted); $notGranted = $this->rightManager->isGranted(LayerType::SOURCE, $this->type, $this->source); $this->assertFalse($notGranted); - $notGranted2 = $this->rightManager->isGranted($this->layer, RightType::WRITE, $this->source); + $notGranted2 = $this->rightManager->isGranted($this->layer, CRUDType::UPDATE, $this->source); $this->assertFalse($notGranted2); $this->right->setGrant(false); $notGranted3 = $this->rightManager->isGranted($this->layer, $this->type, $this->source); @@ -74,7 +74,7 @@ class RightCheckerTest extends TestCase $this->assertTrue($granted); $notGranted = $this->rightManager->isGranted(LayerType::SOURCE, $this->type, $secondSource); $this->assertFalse($notGranted); - $notGranted2 = $this->rightManager->isGranted($this->layer, RightType::WRITE, $secondSource); + $notGranted2 = $this->rightManager->isGranted($this->layer, CRUDType::UPDATE, $secondSource); $this->assertFalse($notGranted2); $this->right->setGrant(false); $notGranted3 = $this->rightManager->isGranted($this->layer, $this->type, $secondSource); @@ -91,7 +91,7 @@ class RightCheckerTest extends TestCase $this->assertTrue($granted); $notGranted = $this->rightManager->isGranted(LayerType::SOURCE, $this->type, $thirdSource); $this->assertFalse($notGranted); - $notGranted2 = $this->rightManager->isGranted($this->layer, RightType::WRITE, $thirdSource); + $notGranted2 = $this->rightManager->isGranted($this->layer, CRUDType::UPDATE, $thirdSource); $this->assertFalse($notGranted2); $this->right->setGrant(false); $notGranted3 = $this->rightManager->isGranted($this->layer, $this->type, $thirdSource); diff --git a/application/tests/Unit/Domain/SecureLoadManagement/SecureSourceLoaderTest.php b/application/tests/Unit/Domain/SecureLoadManagement/SecureSourceLoaderTest.php index 084b9d8..bcdc517 100644 --- a/application/tests/Unit/Domain/SecureLoadManagement/SecureSourceLoaderTest.php +++ b/application/tests/Unit/Domain/SecureLoadManagement/SecureSourceLoaderTest.php @@ -10,8 +10,8 @@ use App\Domain\SecureLoadManagement\SecureSourceLoader; use App\Entity\Source\Primitive\Text\TextSource; use App\DBAL\Types\SystemSlugType; use App\Entity\Meta\Right; -use App\DBAL\Types\LayerType; -use App\DBAL\Types\RightType; +use App\DBAL\Types\Meta\Right\LayerType; +use App\DBAL\Types\Meta\Right\CRUDType; use App\Entity\Source\Complex\UserSource; use App\Entity\Source\Primitive\Text\TextSourceInterface; use Doctrine\ORM\EntityManagerInterface; @@ -52,7 +52,7 @@ class SecureSourceLoaderTest extends KernelTestCase $requestedRight = new Right(); $requestedRight->setSource($requestedSource); $requestedRight->setLayer(LayerType::SOURCE); - $requestedRight->setType(RightType::READ); + $requestedRight->setType(CRUDType::READ); $requestedRight->setReciever(new UserSource()); $secureSourceLoader = new SecureSourceLoader($this->entityManager, $requestedRight); $this->expectException(AccessDeniedHttpException::class); @@ -66,7 +66,7 @@ class SecureSourceLoaderTest extends KernelTestCase $requestedRight = new Right(); $requestedRight->setSource($requestedSource); $requestedRight->setLayer(LayerType::SOURCE); - $requestedRight->setType(RightType::READ); + $requestedRight->setType(CRUDType::READ); $requestedRight->setReciever($this->sourceRepository->findOneBySlug(SystemSlugType::GUEST_USER)); $secureSourceLoader = new SecureSourceLoader($this->entityManager, $requestedRight); $this->assertInstanceOf(TextSourceInterface::class, $secureSourceLoader->getSource()); diff --git a/application/tests/Unit/Domain/SecureSourceManagement/SecureSourceCheckerTest.php b/application/tests/Unit/Domain/SecureSourceManagement/SecureSourceCheckerTest.php index d322d22..fd5ad98 100644 --- a/application/tests/Unit/Domain/SecureSourceManagement/SecureSourceCheckerTest.php +++ b/application/tests/Unit/Domain/SecureSourceManagement/SecureSourceCheckerTest.php @@ -8,8 +8,8 @@ use App\Domain\SecureManagement\SecureSourceCheckerInterface; use App\Entity\Source\AbstractSource; use App\Domain\SecureManagement\SecureSourceChecker; use App\Entity\Meta\Right; -use App\DBAL\Types\LayerType; -use App\DBAL\Types\RightType; +use App\DBAL\Types\Meta\Right\LayerType; +use App\DBAL\Types\Meta\Right\CRUDType; use App\Entity\Attribut\SourceAttribut; use App\Entity\Attribut\SourceAttributInterface; use App\Exception\SourceAccessDenied; @@ -52,13 +52,13 @@ class SecureSourceCheckerTest extends TestCase { $right = new Right(); $right->setLayer(LayerType::SOURCE); - $right->setType(RightType::WRITE); + $right->setType(CRUDType::UPDATE); $right->setReciever($this->recieverSource); $right->setSource($this->source); $this->source->getLaw()->getRights()->add($right); $requestedRight = clone $right; $this->assertTrue($this->securerSourceChecker->hasPermission($requestedRight)); - $requestedRight->setType(RightType::READ); + $requestedRight->setType(CRUDType::READ); $this->assertFalse($this->securerSourceChecker->hasPermission($requestedRight)); } @@ -66,7 +66,7 @@ class SecureSourceCheckerTest extends TestCase { $right = new Right(); $right->setLayer(LayerType::SOURCE); - $right->setType(RightType::WRITE); + $right->setType(CRUDType::UPDATE); $right->setReciever($this->recieverSource); $right->setSource($this->source); $this->source->getLaw()->getRights()->add($right); @@ -76,7 +76,7 @@ class SecureSourceCheckerTest extends TestCase $this->source->setSource($attributSource); $requestedRight = clone $right; $this->assertTrue($this->securerSourceChecker->hasPermission($requestedRight)); - $childRight->setType(RightType::READ); + $childRight->setType(CRUDType::READ); $this->expectException(SourceAccessDenied::class); $this->securerSourceChecker->hasPermission($requestedRight); } @@ -85,7 +85,7 @@ class SecureSourceCheckerTest extends TestCase { $right = new Right(); $right->setLayer(LayerType::SOURCE); - $right->setType(RightType::WRITE); + $right->setType(CRUDType::UPDATE); $right->setReciever($this->recieverSource); $right->setSource($this->source); $this->source->getLaw()->getRights()->add($right); @@ -98,7 +98,7 @@ class SecureSourceCheckerTest extends TestCase $attribut1Source->setSource($attribut2Source); $requestedRight = clone $right; $this->assertTrue($this->securerSourceChecker->hasPermission($requestedRight)); - $childRight->setType(RightType::READ); + $childRight->setType(CRUDType::READ); $this->expectException(SourceAccessDenied::class); $this->securerSourceChecker->hasPermission($requestedRight); } diff --git a/application/tests/Unit/Entity/Attribut/LayerAttributTest.php b/application/tests/Unit/Entity/Attribut/LayerAttributTest.php index df375c4..13affff 100644 --- a/application/tests/Unit/Entity/Attribut/LayerAttributTest.php +++ b/application/tests/Unit/Entity/Attribut/LayerAttributTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Entity\Attribut; use PHPUnit\Framework\TestCase; use App\Entity\Attribut\LayerAttributInterface; use App\Entity\Attribut\LayerAttribut; -use App\DBAL\Types\LayerType; +use App\DBAL\Types\Meta\Right\LayerType; class LayerAttributTest extends TestCase { diff --git a/application/tests/Unit/Entity/Meta/RightTest.php b/application/tests/Unit/Entity/Meta/RightTest.php index 271d9c8..1b1685f 100644 --- a/application/tests/Unit/Entity/Meta/RightTest.php +++ b/application/tests/Unit/Entity/Meta/RightTest.php @@ -3,11 +3,11 @@ namespace tests\unit\Entity; use PHPUnit\Framework\TestCase; -use App\DBAL\Types\RightType; +use App\DBAL\Types\Meta\Right\CRUDType; use App\Entity\Meta\RightInterface; use App\Entity\Meta\Right; use App\Entity\Meta\Law; -use App\DBAL\Types\LayerType; +use App\DBAL\Types\Meta\Right\LayerType; use App\Exception\NoValidChoiceException; use App\Entity\Source\AbstractSource; @@ -73,7 +73,7 @@ class RightTest extends TestCase public function testRight(): void { - foreach (RightType::getChoices() as $key => $value) { + foreach (CRUDType::getChoices() as $key => $value) { $this->assertNull($this->right->setType($key)); $this->assertEquals($key, $this->right->getType()); } @@ -99,7 +99,7 @@ class RightTest extends TestCase $source = $this->createMock(AbstractSource::class); $reciever = $this->createMock(AbstractSource::class); $grant = false; - $type = RightType::READ; + $type = CRUDType::READ; $layer = LayerType::SOURCE; $this->right->setSource($source); $this->right->setReciever($reciever); diff --git a/application/tests/Unit/Repository/RightRepositoryTest.php b/application/tests/Unit/Repository/RightRepositoryTest.php index 44416c5..dc9ac26 100644 --- a/application/tests/Unit/Repository/RightRepositoryTest.php +++ b/application/tests/Unit/Repository/RightRepositoryTest.php @@ -6,8 +6,8 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Doctrine\ORM\EntityRepository; use App\Entity\Meta\RightInterface; use App\Entity\Meta\Right; -use App\DBAL\Types\LayerType; -use App\DBAL\Types\RightType; +use App\DBAL\Types\Meta\Right\LayerType; +use App\DBAL\Types\Meta\Right\CRUDType; use App\Entity\Meta\Law; use App\Entity\Meta\LawInterface; use Doctrine\ORM\EntityManagerInterface; @@ -56,7 +56,7 @@ class RightRepositoryTest extends KernelTestCase $this->right = new Right(); $this->right->setPriority(self::PRIORITY); $this->right->setLayer(LayerType::SOURCE); - $this->right->setType(RightType::READ); + $this->right->setType(CRUDType::READ); $this->law = new Law(); $this->entityManager->persist($this->law); $this->right->setLaw($this->law);