From e9993a2424f900b44afb11eff46ed1979caf4b2f Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 4 Nov 2018 23:43:34 +0100 Subject: [PATCH] Implemented dimensions for reciever --- application/src/Entity/Meta/Reciever.php | 4 +++- .../src/Entity/Meta/RecieverInterface.php | 4 +++- .../tests/Unit/Entity/Meta/RecieverTest.php | 23 ++++++++++--------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/application/src/Entity/Meta/Reciever.php b/application/src/Entity/Meta/Reciever.php index b2e2a3b..8b8115a 100644 --- a/application/src/Entity/Meta/Reciever.php +++ b/application/src/Entity/Meta/Reciever.php @@ -7,6 +7,8 @@ use Doctrine\ORM\Mapping as ORM; use App\Entity\Attribut\MembersAttribut; use App\Entity\Source\SourceInterface; use App\Entity\Attribut\RightAttribut; +use App\Entity\Attribut\CollectionAttribut; +use App\Entity\Method\CollectionDimensionHelperMethod; /** * @author kevinfrantz @@ -15,7 +17,7 @@ use App\Entity\Attribut\RightAttribut; */ class Reciever extends AbstractMeta implements RecieverInterface { - use RightAttribut, MembersAttribut; + use RightAttribut, CollectionAttribut,CollectionDimensionHelperMethod; /** * The right which the reciever group belongs to. diff --git a/application/src/Entity/Meta/RecieverInterface.php b/application/src/Entity/Meta/RecieverInterface.php index 9138ca8..a865221 100644 --- a/application/src/Entity/Meta/RecieverInterface.php +++ b/application/src/Entity/Meta/RecieverInterface.php @@ -4,12 +4,14 @@ namespace App\Entity\Meta; use App\Entity\Attribut\MembersAttributInterface; use App\Entity\Attribut\RightAttributInterface; +use App\Entity\Attribut\CollectionAttributInterface; +use App\Helper\DimensionHelperInterface; /** * It's neccessary to have an own reciever class, because if you would use a GroupSource it would lead to an infinite loop. * * @author kevinfrantz */ -interface RecieverInterface extends MetaInterface, MembersAttributInterface, RightAttributInterface +interface RecieverInterface extends MetaInterface, RightAttributInterface,CollectionAttributInterface,DimensionHelperInterface { } diff --git a/application/tests/Unit/Entity/Meta/RecieverTest.php b/application/tests/Unit/Entity/Meta/RecieverTest.php index f4e3c56..fc7811d 100644 --- a/application/tests/Unit/Entity/Meta/RecieverTest.php +++ b/application/tests/Unit/Entity/Meta/RecieverTest.php @@ -25,43 +25,44 @@ class RecieverTest extends TestCase public function testConstructor(): void { - $this->assertInstanceOf(Collection::class, $this->reciever->getMembers()); + $this->assertInstanceOf(Collection::class, $this->reciever->getCollection()); $this->expectException(\TypeError::class); $this->reciever->getRight(); } - public function testMembersIncludingChildren(): void + public function testDimensions(): void { /** * @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface */ - $user1 = $this->createMock(UserSource::class); + $user1 = new UserSource(); /** * @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface */ - $user2 = $this->createMock(UserSource::class); + $user2 = new UserSource(); /** * @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface */ - $user3 = $this->createMock(UserSource::class); + $user3 = new UserSource(); /** * @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface */ - $group1 = $this->createMock(TreeCollectionSource::class); + $group1 = new TreeCollectionSource(); /** * @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface */ - $group2 = $this->createMock(TreeCollectionSource::class); + $group2 = new TreeCollectionSource(); /** * @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface */ - $group3 = $this->createMock(TreeCollectionSource::class); + $group3 = new TreeCollectionSource(); $group1->getCollection()->add($user1); - $group2->getCollection()->add($group1); + $group1->getCollection()->add($group2); $group2->getCollection()->add($user2); $group2->getCollection()->add($user3); $group2->getCollection()->add($group3); - $this->reciever->getMembers()->add($group1); - $this->assertEquals(6, $this->reciever->getMembersIncludingChildren()->count()); + $this->reciever->getCollection()->add($group1); + $this->assertEquals($group1, $this->reciever->getCollection()->get(0)); + $this->assertEquals(6, $this->reciever->getDimensions()->count()); } }