diff --git a/application/src/Entity/Attribut/GroupSourcesAttribut.php b/application/src/Entity/Attribut/GroupSourcesAttribut.php deleted file mode 100644 index a38ab8a..0000000 --- a/application/src/Entity/Attribut/GroupSourcesAttribut.php +++ /dev/null @@ -1,33 +0,0 @@ -groups; - } - - /** - * @param Collection|GroupSourceInterface[] $groups - */ - public function setGroupSources(Collection $groups): void - { - $this->groups = $groups; - } -} diff --git a/application/src/Entity/Attribut/GroupSourcesAttributInterface.php b/application/src/Entity/Attribut/GroupSourcesAttributInterface.php deleted file mode 100644 index 8a5cfd1..0000000 --- a/application/src/Entity/Attribut/GroupSourcesAttributInterface.php +++ /dev/null @@ -1,22 +0,0 @@ -memberships; + } + + /** + * @param Collection|MemberCollectionSourceInterface[] $memberships + */ + public function setMemberships(Collection $memberships): void + { + $this->memberships = $memberships; + } +} diff --git a/application/src/Entity/Attribut/MembershipsAttributInterface.php b/application/src/Entity/Attribut/MembershipsAttributInterface.php new file mode 100644 index 0000000..2b4cffd --- /dev/null +++ b/application/src/Entity/Attribut/MembershipsAttributInterface.php @@ -0,0 +1,22 @@ +relation = new Relation(); $this->relation->setSource($this); $this->law = new Law(); - $this->groups = new ArrayCollection(); + $this->memberships = new ArrayCollection(); } } diff --git a/application/src/Entity/Source/SourceInterface.php b/application/src/Entity/Source/SourceInterface.php index 93f1514..450c13f 100644 --- a/application/src/Entity/Source/SourceInterface.php +++ b/application/src/Entity/Source/SourceInterface.php @@ -4,13 +4,13 @@ namespace App\Entity\Source; use App\Entity\Attribut\IdAttributInterface; use App\Entity\EntityInterface; -use App\Entity\Attribut\GroupSourcesAttributInterface; use App\Entity\Attribut\LawAttributInterface; use App\Entity\Attribut\RelationAttributInterface; +use App\Entity\Attribut\MembershipsAttributInterface; /** * @author kevinfrantz */ -interface SourceInterface extends IdAttributInterface, EntityInterface, GroupSourcesAttributInterface, LawAttributInterface, RelationAttributInterface +interface SourceInterface extends IdAttributInterface, EntityInterface, MembershipsAttributInterface, LawAttributInterface, RelationAttributInterface { } diff --git a/application/tests/Unit/Entity/Attribut/IdAttributTest.php b/application/tests/Unit/Entity/Attribut/IdAttributTest.php new file mode 100644 index 0000000..f1ac8d6 --- /dev/null +++ b/application/tests/Unit/Entity/Attribut/IdAttributTest.php @@ -0,0 +1,34 @@ +id = new class implements IdAttributInterface{ + use IdAttribut; + }; + } + + public function testConstruct():void{ + $this->expectException(\TypeError::class); + $this->id->getId(); + } + + public function testAccessors():void{ + $id = 1234; + $this->assertNull($this->id->setId($id)); + $this->assertEquals($id, $this->id->getId()); + } + +} + diff --git a/application/tests/Unit/Entity/Attribut/MembersAttributTest.php b/application/tests/Unit/Entity/Attribut/MembersAttributTest.php index 07cad40..0882909 100644 --- a/application/tests/Unit/Entity/Attribut/MembersAttributTest.php +++ b/application/tests/Unit/Entity/Attribut/MembersAttributTest.php @@ -7,6 +7,7 @@ use App\Entity\Attribut\MembersAttributInterface; use Doctrine\Common\Collections\ArrayCollection; use App\Entity\Source\AbstractSource; use App\Tests\AbstractTestCase; +use App\Entity\Source\SourceInterface; class MembersAttributTest extends AbstractTestCase { @@ -49,8 +50,7 @@ class MembersAttributTest extends AbstractTestCase public function testMembersAccessors() { - $source1 = new class() extends AbstractSource { - }; + $source1 = $this->createMock(SourceInterface::class); $source2 = clone $source1; $source3 = clone $source1; $members = new ArrayCollection([ @@ -115,8 +115,7 @@ class MembersAttributTest extends AbstractTestCase public function testMemberWithoutMembers(): void { - $source1 = new class() extends AbstractSource { - }; + $source1 = $this->createMock(SourceInterface::class); $this->membersAttribut->setMembers(new ArrayCollection([$source1])); $this->assertEquals(1, $this->membersAttribut->getMembersIncludingChildren()->count()); } diff --git a/application/tests/Unit/Entity/Attribut/MembershipsAttributTest.php b/application/tests/Unit/Entity/Attribut/MembershipsAttributTest.php new file mode 100644 index 0000000..c0d2c92 --- /dev/null +++ b/application/tests/Unit/Entity/Attribut/MembershipsAttributTest.php @@ -0,0 +1,35 @@ +memberships = new class implements MembershipsAttributInterface{ + use MembershipsAttribut; + }; + } + + public function testConstructor():void { + $this->expectException(\TypeError::class); + $this->memberships->getMemberships(); + } + + public function testAccessors():void { + $membership = $this->createMock(MemberCollectionSourceInterface::class); + $this->assertNull($this->memberships->setMemberships(new ArrayCollection([$membership]))); + $this->assertEquals($this->memberships->getMemberships()->get(0), $membership); + } +} + diff --git a/application/tests/Unit/Entity/Source/AbstractSourceTest.php b/application/tests/Unit/Entity/Source/AbstractSourceTest.php index 59e22df..6c95669 100644 --- a/application/tests/Unit/Entity/Source/AbstractSourceTest.php +++ b/application/tests/Unit/Entity/Source/AbstractSourceTest.php @@ -7,15 +7,14 @@ use App\Entity\Source\SourceInterface; use App\Entity\Meta\LawInterface; use App\Entity\Meta\RelationInterface; use Doctrine\Common\Collections\Collection; -use Doctrine\Common\Collections\ArrayCollection; use App\Entity\Source\AbstractSource; +use App\Entity\EntityInterface; /** * @author kevinfrantz */ class AbstractSourceTest extends TestCase { - const ID = 123; /** * @var SourceInterface */ @@ -23,33 +22,15 @@ class AbstractSourceTest extends TestCase public function setUp() { - $this->source = new class() extends \App\Entity\Source\AbstractSource { + $this->source = new class() extends AbstractSource { }; - $this->source->setId(self::ID); } public function testConstructor(): void { + $this->assertInstanceOf(EntityInterface::class, $this->source); $this->assertInstanceOf(RelationInterface::class, $this->source->getRelation()); - } - - public function testId() - { - $this->assertEquals($this->source->getId(), self::ID); - } - - public function testLaw() - { + $this->assertInstanceOf(Collection::class, $this->source->getMemberships()); $this->assertInstanceOf(LawInterface::class, $this->source->getLaw()); } - - public function testGroups() - { - $this->assertInstanceOf(Collection::class, $this->source->getGroupSources()); - $group = new class() extends AbstractSource { - }; - $groups = new ArrayCollection([$group]); - $this->source->setGroupSources($groups); - $this->assertEquals($group, $this->source->getGroupSources()->get(0)); - } -} +} \ No newline at end of file