diff --git a/application/src/Entity/Meta/Law.php b/application/src/Entity/Meta/Law.php index 24da95f..51d919d 100644 --- a/application/src/Entity/Meta/Law.php +++ b/application/src/Entity/Meta/Law.php @@ -6,7 +6,6 @@ use Doctrine\ORM\Mapping as ORM; use App\Entity\Attribut\RightsAttribute; use Doctrine\Common\Collections\ArrayCollection; use App\Entity\Attribut\RelationAttribut; -use App\Entity\Source\SourceInterface; /** * @author kevinfrantz @@ -25,27 +24,7 @@ final class Law extends AbstractMeta implements LawInterface protected $rights; public function __construct() - { - $this->initAllRights(); - } - - private function initAllRights(): void { $this->rights = new ArrayCollection(); } - - public function isGranted(SourceInterface $source, string $layer, string $right): bool - { - /* - * - * @var RightInterface - */ - foreach ($this->rights->toArray() as $right) { - if ($right->isGranted($relation, $layer, $right)) { - return true; - } - } - - return false; - } } diff --git a/application/src/Entity/Meta/LawInterface.php b/application/src/Entity/Meta/LawInterface.php index 7a08e66..80a9321 100644 --- a/application/src/Entity/Meta/LawInterface.php +++ b/application/src/Entity/Meta/LawInterface.php @@ -3,11 +3,10 @@ namespace App\Entity\Meta; use App\Entity\Attribut\RightsAttributInterface; -use App\Entity\Method\GrantedInterface; /** * @author kevinfrantz */ -interface LawInterface extends RightsAttributInterface, GrantedInterface, MetaInterface +interface LawInterface extends RightsAttributInterface, MetaInterface { } diff --git a/application/src/Entity/Meta/Reciever.php b/application/src/Entity/Meta/Reciever.php index 43f1aa5..881eba7 100644 --- a/application/src/Entity/Meta/Reciever.php +++ b/application/src/Entity/Meta/Reciever.php @@ -7,7 +7,6 @@ use Doctrine\ORM\Mapping as ORM; use App\Entity\Source\SourceInterface; use App\Entity\Attribut\RightAttribut; use App\Entity\Attribut\CollectionAttribut; -use App\Entity\Method\CollectionDimensionHelperMethod; /** * @author kevinfrantz @@ -16,7 +15,7 @@ use App\Entity\Method\CollectionDimensionHelperMethod; */ class Reciever extends AbstractMeta implements RecieverInterface { - use RightAttribut, CollectionAttribut,CollectionDimensionHelperMethod; + use RightAttribut, CollectionAttribut; /** * 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 24deb20..ada3dde 100644 --- a/application/src/Entity/Meta/RecieverInterface.php +++ b/application/src/Entity/Meta/RecieverInterface.php @@ -4,13 +4,12 @@ namespace App\Entity\Meta; 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, RightAttributInterface, CollectionAttributInterface, DimensionHelperInterface +interface RecieverInterface extends MetaInterface, RightAttributInterface, CollectionAttributInterface { } diff --git a/application/src/Entity/Meta/Right.php b/application/src/Entity/Meta/Right.php index e7d87a8..4da8fdf 100644 --- a/application/src/Entity/Meta/Right.php +++ b/application/src/Entity/Meta/Right.php @@ -14,7 +14,6 @@ use App\Entity\Attribut\ConditionAttribut; use App\Entity\Attribut\RecieverAttribut; use App\Entity\Attribut\LayerAttribut; use App\Entity\Attribut\RelationAttribut; -use App\Entity\Source\SourceInterface; /** * @author kevinfrantz @@ -79,27 +78,4 @@ final class Right extends AbstractMeta implements RightInterface $this->reciever = new Reciever(); $this->reciever->setRight($this); } - - public function isGranted(SourceInterface $source, string $layer, string $right): bool - { - if ($this->layer == $layer && $this->type == $right && $this->checkIfNodeIsReciever($relation) && $this->getConditionBoolOrTrue()) { - return $this->grant; - } - - return !($this->grant); - } - - private function getConditionBoolOrTrue(): bool - { - if ($this->hasCondition()) { - return $this->condition->getResult()->getBool(); - } - - return true; - } - - private function checkIfNodeIsReciever(RelationInterface $relation): bool - { - return $this->recieverGroup->getAllRecievers()->contains($relation); - } } diff --git a/application/src/Entity/Meta/RightInterface.php b/application/src/Entity/Meta/RightInterface.php index b97cf4a..57ae557 100644 --- a/application/src/Entity/Meta/RightInterface.php +++ b/application/src/Entity/Meta/RightInterface.php @@ -8,12 +8,11 @@ use App\Entity\Attribut\RecieverAttributInterface; use App\Entity\Attribut\GrantAttributInterface; use App\Entity\Attribut\ConditionAttributInterface; use App\Entity\Attribut\LayerAttributInterface; -use App\Entity\Method\GrantedInterface; use App\Entity\Attribut\RelationAttributInterface; /** * @author kevinfrantz */ -interface RightInterface extends TypeAttributInterface, LawAttributInterface, GrantedInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface +interface RightInterface extends TypeAttributInterface, LawAttributInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface { } diff --git a/application/src/Entity/Method/CollectionDimensionHelperMethod.php b/application/src/Entity/Method/CollectionDimensionHelperMethod.php deleted file mode 100644 index e6d88ab..0000000 --- a/application/src/Entity/Method/CollectionDimensionHelperMethod.php +++ /dev/null @@ -1,22 +0,0 @@ -getDimensions($dimension, $elements); - } -} diff --git a/application/src/Entity/Method/GrantedInterface.php b/application/src/Entity/Method/GrantedInterface.php deleted file mode 100644 index 92b0fbd..0000000 --- a/application/src/Entity/Method/GrantedInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -isActive = true; $this->source = new UserSource(); $this->source->setUser($this); - //LawModificator::grantAllRights($this->source->getNode()->getLaw(), $this->source->getNode()); } } diff --git a/application/tests/Unit/Entity/Meta/RecieverTest.php b/application/tests/Unit/Entity/Meta/RecieverTest.php index fc7811d..69c6a31 100644 --- a/application/tests/Unit/Entity/Meta/RecieverTest.php +++ b/application/tests/Unit/Entity/Meta/RecieverTest.php @@ -6,10 +6,6 @@ use PHPUnit\Framework\TestCase; use App\Entity\Meta\Reciever; use App\Entity\Meta\RecieverInterface; use Doctrine\Common\Collections\Collection; -use App\Entity\Source\Data\UserSource; -use App\Entity\Source\Collection\TreeCollectionSource; -use App\Entity\Source\Collection\TreeCollectionSourceInterface; -use App\Entity\Source\Data\UserSourceInterface; class RecieverTest extends TestCase { @@ -29,40 +25,4 @@ class RecieverTest extends TestCase $this->expectException(\TypeError::class); $this->reciever->getRight(); } - - public function testDimensions(): void - { - /** - * @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface - */ - $user1 = new UserSource(); - /** - * @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface - */ - $user2 = new UserSource(); - /** - * @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface - */ - $user3 = new UserSource(); - /** - * @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface - */ - $group1 = new TreeCollectionSource(); - /** - * @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface - */ - $group2 = new TreeCollectionSource(); - /** - * @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface - */ - $group3 = new TreeCollectionSource(); - $group1->getCollection()->add($user1); - $group1->getCollection()->add($group2); - $group2->getCollection()->add($user2); - $group2->getCollection()->add($user3); - $group2->getCollection()->add($group3); - $this->reciever->getCollection()->add($group1); - $this->assertEquals($group1, $this->reciever->getCollection()->get(0)); - $this->assertEquals(6, $this->reciever->getDimensions()->count()); - } } diff --git a/application/tests/Unit/Entity/Method/CollectionDimensionHelperMethodTest.php b/application/tests/Unit/Entity/Method/CollectionDimensionHelperMethodTest.php deleted file mode 100644 index 512f4be..0000000 --- a/application/tests/Unit/Entity/Method/CollectionDimensionHelperMethodTest.php +++ /dev/null @@ -1,77 +0,0 @@ -collection = new ArrayCollection(); - } - }; - } - - public function setUp(): void - { - $this->method = $this->getClassMock(); - $clone1 = $this->getClassMock(); - $clone2 = $this->getClassMock(); - $clone3 = $this->getClassMock(); - $clone1->getCollection()->add($clone2); - $clone2->getCollection()->add($clone3); - $this->method->getCollection()->add($clone1); - } - - public function testTestSetUp(): void - { - $this->assertEquals(1, $this->method->getCollection()->count()); - $this->assertEquals(1, $this->method->getCollection()->get(0)->getCollection()->count()); - } - - public function testThatZeroAndOneDimensionAreUnique(): void - { - $this->assertFalse($this->method->getDimensions(0)->count() == $this->method->getDimensions(1)->count()); - } - - public function testZeroDimension(): void - { - $this->assertEquals(0, $this->method->getDimensions(0)->count()); - } - - public function testFirstDimension(): void - { - $this->assertEquals(1, $this->method->getDimensions(1)->count()); - } - - public function testSecondDimensionl(): void - { - $this->assertEquals(2, $this->method->getDimensions(2)->count()); - } - - public function testThirdtDimension(): void - { - $this->assertEquals(3, $this->method->getDimensions(3)->count()); - } - - public function testInfiniteDimension(): void - { - $this->assertEquals(3, $this->method->getDimensions()->count()); - } -} diff --git a/application/tests/Unit/Entity/Source/Collection/TreeCollectionSourceTest.php b/application/tests/Unit/Entity/Source/Collection/TreeCollectionSourceTest.php index ecdc4d3..0ebf591 100644 --- a/application/tests/Unit/Entity/Source/Collection/TreeCollectionSourceTest.php +++ b/application/tests/Unit/Entity/Source/Collection/TreeCollectionSourceTest.php @@ -8,7 +8,6 @@ use Doctrine\Common\Collections\ArrayCollection; use App\Entity\Source\AbstractSource; use App\Entity\Source\Collection\TreeCollectionSourceInterface; use App\Entity\Source\Collection\TreeCollectionSource; -use App\Helper\DimensionHelperInterface; /** * @author kevinfrantz @@ -29,7 +28,6 @@ class TreeCollectionSourceTest extends TestCase { $this->assertInstanceOf(Collection::class, $this->tree->getCollection()); $this->assertInstanceOf(TreeCollectionSourceInterface::class, $this->tree); - $this->assertInstanceOf(DimensionHelperInterface::class, $this->tree); } public function testAccessors()