diff --git a/application/src/Entity/Source/Attribut/GroupSourcesAttribut.php b/application/src/Entity/Attribut/GroupSourcesAttribut.php similarity index 93% rename from application/src/Entity/Source/Attribut/GroupSourcesAttribut.php rename to application/src/Entity/Attribut/GroupSourcesAttribut.php index cf61781..a38ab8a 100644 --- a/application/src/Entity/Source/Attribut/GroupSourcesAttribut.php +++ b/application/src/Entity/Attribut/GroupSourcesAttribut.php @@ -1,6 +1,6 @@ membersAttribut = new class() implements MembersAttributInterface { + $this->membersAttribut = $this->getMembersAttributClassMock(); + } + + private function getMembersAttributClassMock():MembersAttributInterface{ + return new class implements MembersAttributInterface{ use MembersAttribut; }; } @@ -62,7 +65,7 @@ class MembersAttributTest extends AbstractTestCase public function testFirstLevelMembersInclusiveChildren(): void { - $source1 = new GroupSource(); + $source1 = $this->getMembersAttributClassMock(); $source2 = clone $source1; $source3 = clone $source1; $source4 = clone $source1; @@ -74,13 +77,14 @@ class MembersAttributTest extends AbstractTestCase public function test3DimensionsMembersInclusiveChildren(): void { - $source1 = new GroupSource(); + $source1 = $this->getMembersAttributClassMock(); $source2 = clone $source1; $source3 = clone $source1; $source4 = clone $source1; $source1->setMembers(new ArrayCollection([$source2])); $source2->setMembers(new ArrayCollection([$source3])); $source3->setMembers(new ArrayCollection([$source4])); + $source4->setMembers(new ArrayCollection()); $this->membersAttribut->setMembers(new ArrayCollection([$source1])); $this->assertEquals(1, $this->membersAttribut->getMembers()->count()); $this->assertEquals(1, $source1->getMembers()->count()); @@ -92,7 +96,8 @@ class MembersAttributTest extends AbstractTestCase public function testMembersIncludingChildrenInfinite(): void { - $source1 = new GroupSource(); + $source1 = $this->getMembersAttributClassMock(); + $source1->setMembers(new ArrayCollection()); $source2 = clone $source1; $source3 = clone $source1; $source4 = clone $source1; diff --git a/application/tests/Unit/Entity/Source/Collection/MemberCollectionSourceTest.php b/application/tests/Unit/Entity/Source/Collection/MemberCollectionSourceTest.php new file mode 100644 index 0000000..fe567ae --- /dev/null +++ b/application/tests/Unit/Entity/Source/Collection/MemberCollectionSourceTest.php @@ -0,0 +1,43 @@ +groupSource = new MemberCollectionSource(); + } + + public function testConstructor(): void + { + $this->assertInstanceOf(Collection::class, $this->groupSource->getMembers()); + } + + public function testMembers() + { + $member = new class() extends AbstractSource {}; + $this->groupSource->setMembers(new ArrayCollection([ + $member + ])); + $this->assertEquals($member, $this->groupSource->getMembers() + ->get(0)); + } +} diff --git a/application/tests/Unit/Entity/Source/GroupSourceTest.php b/application/tests/Unit/Entity/Source/GroupSourceTest.php deleted file mode 100644 index d78fa29..0000000 --- a/application/tests/Unit/Entity/Source/GroupSourceTest.php +++ /dev/null @@ -1,35 +0,0 @@ -groupSource = new GroupSource(); - } - - public function testMembers() - { - $this->assertInstanceOf(Collection::class, $this->groupSource->getMembers()); - $member = new class() extends AbstractSource { - }; - $this->groupSource->setMembers(new ArrayCollection([$member])); - $this->assertEquals($member, $this->groupSource->getMembers()->get(0)); - } -}