From 25ed71221d1937ea81f78b53949c0f619463c8f0 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 30 Dec 2018 00:31:03 +0100 Subject: [PATCH] Optimized testing --- .../LawPermissionCheckerTest.php | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/application/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php b/application/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php index 35e71dc..9026358 100644 --- a/application/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php +++ b/application/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php @@ -117,22 +117,24 @@ class LawPermissionCheckerTest extends TestCase $this->assertFalse($this->checkClientPermission()); } -// /** -// * @todo Implement! -// */ -// public function testChildMemberPermission(): void -// { -// $parentSource = $this->getSourceMock(); -// $parentSource->setSlug('Parent Source'); -// $sourceMemberManager = new SourceMemberManager($parentSource); -// $sourceMemberManager->addMember($this->clientSource); -// $parentSourceRight = $this->getClonedClientRight(); -// $parentSourceRight->setReciever($parentSource); -// $this->law->getRights()->add($parentSourceRight); -// $this->assertTrue($this->checkClientPermission()); -// $this->law->setRights(new ArrayCollection()); -// $this->assertFalse($this->checkClientPermission()); -// } + public function testChildMemberPermission(): void + { + $parentSource = $this->getSourceMock(); + $parentSource->setSlug('Parent Source'); + $parentSourceMemberManager = new SourceMemberManager($parentSource); + $parentSourceMemberManager->addMember($this->clientSource); + $this->assertEquals($parentSource, $this->clientSource->getMemberRelation()->getMemberships()->get(0)->getSource()); + $this->assertEquals($this->clientSource, $parentSource->getMemberRelation()->getMembers()->get(0)->getSource()); + $parentSourceRight = $this->getClonedClientRight(); + $parentSourceRight->setReciever($parentSource); + $this->law->getRights()->add($parentSourceRight); + $this->assertEquals($parentSourceRight, $this->law->getRights()->get(0)); + $this->assertEquals($parentSource, $parentSourceRight->getReciever()); + $this->assertEquals($this->source, $parentSourceRight->getSource()); + $this->assertTrue($this->checkClientPermission()); + $this->law->setRights(new ArrayCollection()); + $this->assertFalse($this->checkClientPermission()); + } public function testGetRightsByType(): void {