diff --git a/application/src/Entity/Attribut/CreatorRelationAttribut.php b/application/src/Entity/Attribut/CreatorRelationAttribut.php new file mode 100644 index 0000000..7c15a1d --- /dev/null +++ b/application/src/Entity/Attribut/CreatorRelationAttribut.php @@ -0,0 +1,21 @@ +creatorRelation = $creatorRelation; + } + + public function getCreatorRelation():CreatorRelationInterface{ + return $this->creatorRelation; + } +} + diff --git a/application/src/Entity/Attribut/CreatorRelationAttributInterface.php b/application/src/Entity/Attribut/CreatorRelationAttributInterface.php new file mode 100644 index 0000000..b1f89c5 --- /dev/null +++ b/application/src/Entity/Attribut/CreatorRelationAttributInterface.php @@ -0,0 +1,11 @@ +parentRelation = $parentRelation; + } + + public function getParentRelation():ParentRelationInterface{ + return $this->parentRelation; + } +} \ No newline at end of file diff --git a/application/src/Entity/Attribut/ParentRelationAttributInterface.php b/application/src/Entity/Attribut/ParentRelationAttributInterface.php new file mode 100644 index 0000000..2c24e26 --- /dev/null +++ b/application/src/Entity/Attribut/ParentRelationAttributInterface.php @@ -0,0 +1,12 @@ +relation = new Relation(); - $this->relation->setSource($this); + $this->creatorRelation = new CreatorRelation(); + $this->creatorRelation->setSource($this); $this->law = new Law(); + $this->law->setSource($this); + /** + * + * @todo Refactor the following attibutes + */ $this->memberships = new ArrayCollection(); $this->members = new ArrayCollection(); } diff --git a/application/src/Entity/Source/SourceInterface.php b/application/src/Entity/Source/SourceInterface.php index 608fa39..5a77a92 100644 --- a/application/src/Entity/Source/SourceInterface.php +++ b/application/src/Entity/Source/SourceInterface.php @@ -5,14 +5,14 @@ namespace App\Entity\Source; use App\Entity\Attribut\IdAttributInterface; use App\Entity\EntityInterface; use App\Entity\Attribut\LawAttributInterface; -use App\Entity\Attribut\RelationAttributInterface; use App\Entity\Attribut\MembershipsAttributInterface; use App\Entity\Attribut\SlugAttributInterface; use App\Entity\Attribut\MembersAttributInterface; +use App\Entity\Attribut\CreatorRelationAttributInterface; /** * @author kevinfrantz */ -interface SourceInterface extends IdAttributInterface, EntityInterface, MembershipsAttributInterface, LawAttributInterface, RelationAttributInterface, SlugAttributInterface, MembersAttributInterface +interface SourceInterface extends IdAttributInterface, EntityInterface, MembershipsAttributInterface, LawAttributInterface, SlugAttributInterface, MembersAttributInterface,CreatorRelationAttributInterface { } diff --git a/application/tests/Unit/Entity/Attribut/CreatorRelationAttributTest.php b/application/tests/Unit/Entity/Attribut/CreatorRelationAttributTest.php new file mode 100644 index 0000000..f2ee5f1 --- /dev/null +++ b/application/tests/Unit/Entity/Attribut/CreatorRelationAttributTest.php @@ -0,0 +1,33 @@ +creatorRelationAttribut = new class() implements CreatorRelationAttributInterface { + use CreatorRelationAttribut; + }; + } + + public function testAccessors(): void + { + $relation = $this->createMock(CreatorRelationInterface::class); + $this->assertNull($this->creatorRelationAttribut->setCreatorRelation($relation)); + $this->assertEquals($relation, $this->creatorRelationAttribut->getCreatorRelation()); + } +} diff --git a/application/tests/Unit/Entity/Attribut/ParentRelationAttributTest.php b/application/tests/Unit/Entity/Attribut/ParentRelationAttributTest.php new file mode 100644 index 0000000..8240f60 --- /dev/null +++ b/application/tests/Unit/Entity/Attribut/ParentRelationAttributTest.php @@ -0,0 +1,30 @@ +parentRelationAttribut = new class() implements ParentRelationAttributInterface { + use ParentRelationAttribut; + }; + } + + public function testAccessors(): void + { + $relation = $this->createMock(ParentRelationInterface::class); + $this->assertNull($this->parentRelationAttribut->setParentRelation($relation)); + $this->assertEquals($relation, $this->parentRelationAttribut->getParentRelation()); + } +} diff --git a/application/tests/Unit/Entity/Source/AbstractSourceTest.php b/application/tests/Unit/Entity/Source/AbstractSourceTest.php index dfb1a98..e538d4d 100644 --- a/application/tests/Unit/Entity/Source/AbstractSourceTest.php +++ b/application/tests/Unit/Entity/Source/AbstractSourceTest.php @@ -9,6 +9,7 @@ use App\Entity\Meta\RelationInterface; use Doctrine\Common\Collections\Collection; use App\Entity\Source\AbstractSource; use App\Entity\EntityInterface; +use App\Entity\Meta\Relation\CreatorRelationInterface; /** * @author kevinfrantz @@ -34,9 +35,11 @@ class AbstractSourceTest extends TestCase public function testConstructor(): void { $this->assertInstanceOf(EntityInterface::class, $this->source); - $this->assertInstanceOf(RelationInterface::class, $this->source->getRelation()); + $this->assertInstanceOf(CreatorRelationInterface::class, $this->source->getCreatorRelation()); + $this->assertEquals($this->source, $this->source->getCreatorRelation()->getSource()); $this->assertInstanceOf(Collection::class, $this->source->getMemberships()); $this->assertInstanceOf(LawInterface::class, $this->source->getLaw()); + $this->assertEquals($this->source, $this->source->getLaw()->getSource()); $this->assertInstanceOf(Collection::class, $this->source->getMembers()); }