From 94b84527a8b3d22dcfc67c2a78506492c5904e63 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Fri, 29 Mar 2019 17:53:06 +0100 Subject: [PATCH] Optimized MVC and implemented function tests for format --- .../symfony/src/Attribut/RelationAttribut.php | 12 +++++ .../Attribut/RelationAttributInterface.php | 6 +++ .../src/DBAL/Types/Meta/Right/LayerType.php | 15 ++++++ .../MVCManagement/MVCRoutineService.php | 6 ++- .../ProcessManagement/ProcessService.php | 4 +- .../ProcessServiceInterface.php | 5 +- application/symfony/src/Entity/Meta/Right.php | 5 +- .../src/Entity/Meta/RightInterface.php | 3 +- .../tests/Functional/FormatFunctionTest.php | 46 +++++++++++++++++++ 9 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 application/symfony/tests/Functional/FormatFunctionTest.php diff --git a/application/symfony/src/Attribut/RelationAttribut.php b/application/symfony/src/Attribut/RelationAttribut.php index 1544c82..92c4737 100644 --- a/application/symfony/src/Attribut/RelationAttribut.php +++ b/application/symfony/src/Attribut/RelationAttribut.php @@ -6,6 +6,8 @@ use Infinito\Entity\Meta\Relation\RelationInterface; /** * @author kevinfrantz + * + * @see RelationAttributInterface */ trait RelationAttribut { @@ -14,11 +16,21 @@ trait RelationAttribut */ protected $relation; + /** + * @param RelationInterface $relation + * + * @see RelationAttributInterface + */ public function setRelation(RelationInterface $relation): void { $this->relation = $relation; } + /** + * @see RelationAttributInterface + * + * @return RelationInterface + */ public function getRelation(): RelationInterface { return $this->relation; diff --git a/application/symfony/src/Attribut/RelationAttributInterface.php b/application/symfony/src/Attribut/RelationAttributInterface.php index 98dc2e2..d867283 100644 --- a/application/symfony/src/Attribut/RelationAttributInterface.php +++ b/application/symfony/src/Attribut/RelationAttributInterface.php @@ -9,7 +9,13 @@ use Infinito\Entity\Meta\Relation\RelationInterface; */ interface RelationAttributInterface { + /** + * @param RelationInterface $relation + */ public function setRelation(RelationInterface $relation): void; + /** + * @return RelationInterface + */ public function getRelation(): RelationInterface; } diff --git a/application/symfony/src/DBAL/Types/Meta/Right/LayerType.php b/application/symfony/src/DBAL/Types/Meta/Right/LayerType.php index 29633a7..c9adeaa 100644 --- a/application/symfony/src/DBAL/Types/Meta/Right/LayerType.php +++ b/application/symfony/src/DBAL/Types/Meta/Right/LayerType.php @@ -11,14 +11,29 @@ use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType; */ final class LayerType extends AbstractEnumType { + /** + * @var string + */ public const HEREDITY = 'heredity'; + /** + * @var string + */ public const RIGHT = 'right'; + /** + * @var string + */ public const SOURCE = 'source'; + /** + * @var string + */ public const LAW = 'law'; + /** + * @var string + */ public const MEMBER = 'member'; const CREATOR = 'creator'; diff --git a/application/symfony/src/Domain/MVCManagement/MVCRoutineService.php b/application/symfony/src/Domain/MVCManagement/MVCRoutineService.php index f8d0cb8..ef1002b 100644 --- a/application/symfony/src/Domain/MVCManagement/MVCRoutineService.php +++ b/application/symfony/src/Domain/MVCManagement/MVCRoutineService.php @@ -44,8 +44,10 @@ final class MVCRoutineService implements MVCRoutineServiceInterface */ public function process(): View { - $this->processService->process(); + $data = $this->processService->process(); + $view = $this->viewBuilder->getView(); + $view->setData($data); - return $this->viewBuilder->getView(); + return $view; } } diff --git a/application/symfony/src/Domain/ProcessManagement/ProcessService.php b/application/symfony/src/Domain/ProcessManagement/ProcessService.php index 174591f..877226b 100644 --- a/application/symfony/src/Domain/ProcessManagement/ProcessService.php +++ b/application/symfony/src/Domain/ProcessManagement/ProcessService.php @@ -70,7 +70,7 @@ final class ProcessService implements ProcessServiceInterface * * @see \Infinito\Domain\ProcessManagement\ProcessServiceInterface::process() */ - public function process(): void + public function process() { if ($this->requestedActionService->hasRequestedEntity() && $this->requestedActionService->getRequestedEntity()->hasIdentity()) { // READ VIEW @@ -95,5 +95,7 @@ final class ProcessService implements ProcessServiceInterface ->createView(); $this->actionTemplateDataStore->setData(ActionType::CREATE, $updateForm); } + + return $this->actionTemplateDataStore; } } diff --git a/application/symfony/src/Domain/ProcessManagement/ProcessServiceInterface.php b/application/symfony/src/Domain/ProcessManagement/ProcessServiceInterface.php index 813478a..2396c85 100644 --- a/application/symfony/src/Domain/ProcessManagement/ProcessServiceInterface.php +++ b/application/symfony/src/Domain/ProcessManagement/ProcessServiceInterface.php @@ -7,5 +7,8 @@ namespace Infinito\Domain\ProcessManagement; */ interface ProcessServiceInterface { - public function process(): void; + /** + * @todo specify return type + */ + public function process(); } diff --git a/application/symfony/src/Entity/Meta/Right.php b/application/symfony/src/Entity/Meta/Right.php index 3d87d03..a72289d 100644 --- a/application/symfony/src/Entity/Meta/Right.php +++ b/application/symfony/src/Entity/Meta/Right.php @@ -10,21 +10,18 @@ use Infinito\Logic\Operation\OperationInterface; use Infinito\Attribut\ConditionAttribut; use Infinito\Attribut\RecieverAttribut; use Infinito\Attribut\LayerAttribut; -use Infinito\Attribut\RelationAttribut; use Infinito\Attribut\PriorityAttribut; use Infinito\Entity\Source\SourceInterface; use Infinito\Attribut\ActionTypeAttribut; /** - * @todo Remove relation attribut! - * * @author kevinfrantz * @ORM\Table(name="meta_right") * @ORM\Entity(repositoryClass="Infinito\Repository\Meta\RightRepository") */ class Right extends AbstractMeta implements RightInterface { - use ActionTypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverAttribut,LayerAttribut,PriorityAttribut; + use ActionTypeAttribut,LawAttribut, GrantAttribut,ConditionAttribut,RecieverAttribut,LayerAttribut,PriorityAttribut; /** * @ORM\OneToOne(targetEntity="Infinito\Entity\Source\AbstractSource",cascade={"persist", "remove"}) diff --git a/application/symfony/src/Entity/Meta/RightInterface.php b/application/symfony/src/Entity/Meta/RightInterface.php index 7f2b4d5..caa71ec 100644 --- a/application/symfony/src/Entity/Meta/RightInterface.php +++ b/application/symfony/src/Entity/Meta/RightInterface.php @@ -7,13 +7,12 @@ use Infinito\Attribut\RecieverAttributInterface; use Infinito\Attribut\GrantAttributInterface; use Infinito\Attribut\ConditionAttributInterface; use Infinito\Attribut\LayerAttributInterface; -use Infinito\Attribut\RelationAttributInterface; use Infinito\Attribut\PriorityAttributInterface; use Infinito\Attribut\ActionTypeAttributInterface; /** * @author kevinfrantz */ -interface RightInterface extends ActionTypeAttributInterface, LawAttributInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface, PriorityAttributInterface +interface RightInterface extends ActionTypeAttributInterface, LawAttributInterface, GrantAttributInterface, RecieverAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface, PriorityAttributInterface { } diff --git a/application/symfony/tests/Functional/FormatFunctionTest.php b/application/symfony/tests/Functional/FormatFunctionTest.php new file mode 100644 index 0000000..b157cc4 --- /dev/null +++ b/application/symfony/tests/Functional/FormatFunctionTest.php @@ -0,0 +1,46 @@ +request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE'); + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertContains('getResponse()->getContent()); + } + + public function testHomepageWithHTML(): void + { + $client = static::createClient(); + $client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html'); + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertContains('getResponse()->getContent()); + } + + public function testHomepageWithJSON(): void + { + $client = static::createClient(); + $client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.json'); + echo $client->getResponse()->getContent(); + $this->assertEquals(200, $client->getResponse()->getStatusCode()); +// $this->assertContains('getResponse()->getContent()); + } + + public function testHomepageWithXML(): void + { + $client = static::createClient(); + $client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.xml'); + echo $client->getResponse()->getContent(); + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + // $this->assertContains('getResponse()->getContent()); + } +}