diff --git a/application/symfony/src/Attribut/RequestedEntityAttribut.php b/application/symfony/src/Attribut/RequestedEntityAttribut.php new file mode 100644 index 0000000..eefbbff --- /dev/null +++ b/application/symfony/src/Attribut/RequestedEntityAttribut.php @@ -0,0 +1,32 @@ +requestedEntity; + } + + /** + * @param RequestedEntityInterface $requestedEntity + */ + public function setRequestedEntity(RequestedEntityInterface $requestedEntity): void + { + $this->requestedEntity = $requestedEntity; + } +} diff --git a/application/symfony/src/Attribut/RequestedEntityAttributInterface.php b/application/symfony/src/Attribut/RequestedEntityAttributInterface.php new file mode 100644 index 0000000..d3a3c40 --- /dev/null +++ b/application/symfony/src/Attribut/RequestedEntityAttributInterface.php @@ -0,0 +1,21 @@ +source = $this->sourceRepository->findOneByIdOrSlug($this->requestedSource); + $this->source = $this->sourceRepository->findOneByIdOrSlug($this->requestedEntity); } /** @@ -53,10 +53,10 @@ class RequestedRight implements RequestedRightInterface */ private function validateRequestedEntity(): void { - if ($this->requestedSource->hasSlug() || $this->requestedSource->hasId()) { + if ($this->requestedEntity->hasSlug() || $this->requestedEntity->hasId()) { return; } - throw new PreconditionFailedException(get_class($this->requestedSource).' needs to have a defined attribut id or slug!'); + throw new PreconditionFailedException(get_class($this->requestedEntity).' needs to have a defined attribut id or slug!'); } /** @@ -88,8 +88,8 @@ class RequestedRight implements RequestedRightInterface * * @see \App\Domain\RequestManagement\Right\RequestedRightInterface::setRequestedEntity() */ - final public function setRequestedEntity(RequestedEntityInterface $requestedSource) + final public function setRequestedEntity(RequestedEntityInterface $requestedSource): void { - $this->requestedSource = $requestedSource; + $this->requestedEntity = $requestedSource; } } diff --git a/application/symfony/src/Domain/RequestManagement/Right/RequestedRightInterface.php b/application/symfony/src/Domain/RequestManagement/Right/RequestedRightInterface.php index f5d5d36..c65d176 100644 --- a/application/symfony/src/Domain/RequestManagement/Right/RequestedRightInterface.php +++ b/application/symfony/src/Domain/RequestManagement/Right/RequestedRightInterface.php @@ -16,7 +16,7 @@ interface RequestedRightInterface extends CrudAttributInterface, RecieverAttribu /** * @param RequestedEntityInterface $requestedSource */ - public function setRequestedEntity(RequestedEntityInterface $requestedSource); + public function setRequestedEntity(RequestedEntityInterface $requestedSource): void; /** * {@inheritdoc} diff --git a/application/symfony/src/Domain/RequestManagement/User/RequestedUser.php b/application/symfony/src/Domain/RequestManagement/User/RequestedUser.php index b4e7bc0..5699cde 100644 --- a/application/symfony/src/Domain/RequestManagement/User/RequestedUser.php +++ b/application/symfony/src/Domain/RequestManagement/User/RequestedUser.php @@ -105,7 +105,7 @@ class RequestedUser implements RequestedUserInterface /** * @param RequestedEntityInterface $requestedSource */ - public function setRequestedEntity(RequestedEntityInterface $requestedSource) + public function setRequestedEntity(RequestedEntityInterface $requestedSource): void { $this->requestedRight->setRequestedEntity($requestedSource); } diff --git a/application/symfony/tests/Unit/Attribut/RequestedEntityAttributTest.php b/application/symfony/tests/Unit/Attribut/RequestedEntityAttributTest.php new file mode 100644 index 0000000..cb86460 --- /dev/null +++ b/application/symfony/tests/Unit/Attribut/RequestedEntityAttributTest.php @@ -0,0 +1,39 @@ +requestedEntityAttribut = new class() implements RequestedEntityAttributInterface { + use RequestedEntityAttribut; + }; + } + + public function testConstructor(): void + { + $this->expectException(\TypeError::class); + $this->requestedEntityAttribut->getRequestedEntity(); + } + + public function testAccessors(): void + { + $requestedEntity = $this->createMock(RequestedEntityInterface::class); + $this->assertNull($this->requestedEntityAttribut->setRequestedEntity($requestedEntity)); + $this->assertEquals($requestedEntity, $this->requestedEntityAttribut->getRequestedEntity()); + } +}