mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 09:19:08 +00:00 
			
		
		
		
	Refactored code through substituting by PureSource
This commit is contained in:
		| @@ -12,6 +12,7 @@ use App\DBAL\Types\LayerType; | ||||
| use App\DBAL\Types\RightType; | ||||
| use App\Domain\UserManagement\UserIdentityManager; | ||||
| use Doctrine\ORM\EntityManagerInterface; | ||||
| use App\Entity\Source\PureSource; | ||||
|  | ||||
| /** | ||||
|  * This controller offers the standart routes for the template. | ||||
| @@ -28,8 +29,7 @@ final class DefaultController extends AbstractEntityController | ||||
|     { | ||||
|         $userIdentityManager = new UserIdentityManager($entityManager, $this->getUser()); | ||||
|         $user = $userIdentityManager->getUser(); | ||||
|         $requestedSource = new class() extends AbstractSource { | ||||
|         }; | ||||
|         $requestedSource = new PureSource(); | ||||
|         $requestedSource->setSlug(SystemSlugType::IMPRINT); | ||||
|         $requestedRight = new Right(); | ||||
|         $requestedRight->setSource($requestedSource); | ||||
|   | ||||
| @@ -5,10 +5,10 @@ namespace Tests\Integration\Domain\SourceManagement; | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use App\Entity\Source\SourceInterface; | ||||
| use App\Domain\SourceManagement\SourceMemberManagerInterface; | ||||
| use App\Entity\Source\AbstractSource; | ||||
| use App\Domain\SourceManagement\SourceMemberManager; | ||||
| use App\Domain\SourceManagement\SourceMemberInformation; | ||||
| use App\Domain\SourceManagement\SourceMembershipInformation; | ||||
| use App\Entity\Source\PureSource; | ||||
|  | ||||
| class SourceMemberManagerIntegrationTest extends TestCase | ||||
| { | ||||
| @@ -22,21 +22,15 @@ class SourceMemberManagerIntegrationTest extends TestCase | ||||
|      */ | ||||
|     private $sourceMemberManager; | ||||
|  | ||||
|     private function createSource(): SourceInterface | ||||
|     { | ||||
|         return new class() extends AbstractSource { | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public function setUp(): void | ||||
|     { | ||||
|         $this->source = $this->createSource(); | ||||
|         $this->source = new PureSource(); | ||||
|         $this->sourceMemberManager = new SourceMemberManager($this->source); | ||||
|     } | ||||
|  | ||||
|     public function testSourceMemberInformationIntegration(): void | ||||
|     { | ||||
|         $childSource = $this->createSource(); | ||||
|         $childSource = new PureSource(); | ||||
|         $sourceMemberInformation = new SourceMemberInformation($this->source); | ||||
|         $this->sourceMemberManager->addMember($childSource); | ||||
|         $this->assertEquals($childSource, $sourceMemberInformation->getAllMembers()->get(0)); | ||||
| @@ -46,7 +40,7 @@ class SourceMemberManagerIntegrationTest extends TestCase | ||||
|  | ||||
|     public function testSourceMembershipInformationIntegration(): void | ||||
|     { | ||||
|         $parentSource = $this->createSource(); | ||||
|         $parentSource = new PureSource(); | ||||
|         $sourceMemberInformation = new SourceMembershipInformation($this->source); | ||||
|         $this->sourceMemberManager->addMembership($parentSource); | ||||
|         $this->assertEquals($parentSource, $sourceMemberInformation->getAllMemberships()->get(0)); | ||||
|   | ||||
| @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; | ||||
| use App\Domain\LawManagement\LawPermissionCheckerService; | ||||
| use App\Domain\LawManagement\LawPermissionCheckerServiceInterface; | ||||
| use App\Entity\Source\SourceInterface; | ||||
| use App\Entity\Source\AbstractSource; | ||||
| use App\Entity\Meta\Right; | ||||
| use App\DBAL\Types\LayerType; | ||||
| use App\DBAL\Types\RightType; | ||||
| @@ -15,6 +14,7 @@ use App\Entity\Meta\LawInterface; | ||||
| use App\Entity\Meta\RightInterface; | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use App\Domain\SourceManagement\SourceMemberManager; | ||||
| use App\Entity\Source\PureSource; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
| @@ -46,12 +46,6 @@ class LawPermissionCheckerTest extends TestCase | ||||
|      */ | ||||
|     private $source; | ||||
|  | ||||
|     private function getSourceMock(): SourceInterface | ||||
|     { | ||||
|         return new class() extends AbstractSource { | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     private function checkClientPermission(): bool | ||||
|     { | ||||
|         return $this->lawPermissionChecker->hasPermission($this->clientRight); | ||||
| @@ -79,13 +73,13 @@ class LawPermissionCheckerTest extends TestCase | ||||
|  | ||||
|     private function setSourceDummy(): void | ||||
|     { | ||||
|         $this->source = $this->getSourceMock(); | ||||
|         $this->source = new PureSource(); | ||||
|         $this->source->setSlug('Requested Source'); | ||||
|     } | ||||
|  | ||||
|     private function setClientSourceDummy(): void | ||||
|     { | ||||
|         $this->clientSource = $this->getSourceMock(); | ||||
|         $this->clientSource = new PureSource(); | ||||
|         $this->clientSource->setSlug('Client Source'); | ||||
|     } | ||||
|  | ||||
| @@ -119,7 +113,7 @@ class LawPermissionCheckerTest extends TestCase | ||||
|  | ||||
|     public function testChildMemberPermission(): void | ||||
|     { | ||||
|         $parentSource = $this->getSourceMock(); | ||||
|         $parentSource = new PureSource(); | ||||
|         $parentSource->setSlug('Parent Source'); | ||||
|         $parentSourceMemberManager = new SourceMemberManager($parentSource); | ||||
|         $parentSourceMemberManager->addMember($this->clientSource); | ||||
| @@ -190,7 +184,7 @@ class LawPermissionCheckerTest extends TestCase | ||||
|         $right1 = $this->getClonedClientRight(); | ||||
|         $right1->setPriority(123); | ||||
|         $right1->setGrant(false); | ||||
|         $right1->setReciever($this->getSourceMock()); | ||||
|         $right1->setReciever(new PureSource()); | ||||
|         $right1->getReciever()->setSlug('Rigth1 Reciever'); | ||||
|         $right2 = $this->getClonedClientRight(); | ||||
|         $right2->setPriority(456); | ||||
|   | ||||
| @@ -6,11 +6,11 @@ use PHPUnit\Framework\TestCase; | ||||
| use App\Entity\Meta\RightInterface; | ||||
| use App\Entity\Meta\Right; | ||||
| use App\Entity\Source\SourceInterface; | ||||
| use App\Entity\Source\AbstractSource; | ||||
| use App\DBAL\Types\LayerType; | ||||
| use App\Domain\RightManagement\RightCheckerInterface; | ||||
| use App\Domain\RightManagement\RightChecker; | ||||
| use App\DBAL\Types\RightType; | ||||
| use App\Entity\Source\PureSource; | ||||
|  | ||||
| class RightCheckerTest extends TestCase | ||||
| { | ||||
| @@ -39,17 +39,11 @@ class RightCheckerTest extends TestCase | ||||
|      */ | ||||
|     private $rightManager; | ||||
|  | ||||
|     private function getSourceMock(): SourceInterface | ||||
|     { | ||||
|         return new class() extends AbstractSource { | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public function setUp(): void | ||||
|     { | ||||
|         $this->layer = LayerType::RELATION; | ||||
|         $this->type = RightType::READ; | ||||
|         $this->source = $this->getSourceMock(); | ||||
|         $this->source = new PureSource(); | ||||
|         $this->right = new Right(); | ||||
|         $this->right->setReciever($this->source); | ||||
|         $this->right->setType($this->type); | ||||
| @@ -68,13 +62,13 @@ class RightCheckerTest extends TestCase | ||||
|         $this->right->setGrant(false); | ||||
|         $notGranted3 = $this->rightManager->isGranted($this->layer, $this->type, $this->source); | ||||
|         $this->assertFalse($notGranted3); | ||||
|         $notGranted4 = $this->rightManager->isGranted($this->layer, $this->type, $this->getSourceMock()); | ||||
|         $notGranted4 = $this->rightManager->isGranted($this->layer, $this->type, new PureSource()); | ||||
|         $this->assertFalse($notGranted4); | ||||
|     } | ||||
|  | ||||
|     public function testSecondDimension(): void | ||||
|     { | ||||
|         $secondSource = $this->getSourceMock(); | ||||
|         $secondSource = new PureSource(); | ||||
|         $this->source->getMemberRelation()->getMembers()->add($secondSource->getMemberRelation()); | ||||
|         $granted = $this->rightManager->isGranted($this->layer, $this->type, $secondSource); | ||||
|         $this->assertTrue($granted); | ||||
| @@ -89,8 +83,8 @@ class RightCheckerTest extends TestCase | ||||
|  | ||||
|     public function testThirdDimension(): void | ||||
|     { | ||||
|         $thirdSource = $this->getSourceMock(); | ||||
|         $secondSource = $this->getSourceMock(); | ||||
|         $thirdSource = new PureSource(); | ||||
|         $secondSource = new PureSource(); | ||||
|         $secondSource->getMemberRelation()->getMembers()->add($thirdSource->getMemberRelation()); | ||||
|         $this->source->getMemberRelation()->getMembers()->add($secondSource->getMemberRelation()); | ||||
|         $granted = $this->rightManager->isGranted($this->layer, $this->type, $thirdSource); | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Tests\Unit\Domain; | ||||
| namespace Tests\Unit\Domain\SecureSourceManagement; | ||||
| 
 | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use App\Entity\Source\SourceInterface; | ||||
| @@ -11,7 +11,7 @@ use Doctrine\Common\Collections\ArrayCollection; | ||||
| use App\Entity\Source\Complex\FullPersonNameSource; | ||||
| use App\Domain\SourceManagement\SourceMemberInformation; | ||||
| use App\Domain\SourceManagement\SourceMemberInformationInterface; | ||||
| use App\Entity\Source\AbstractSource; | ||||
| use App\Entity\Source\PureSource; | ||||
|  | ||||
| class SourceMemberInformationTest extends TestCase | ||||
| { | ||||
| @@ -25,12 +25,6 @@ class SourceMemberInformationTest extends TestCase | ||||
|      */ | ||||
|     private $sourceMemberInformation; | ||||
|  | ||||
|     private function createSourceMock(): SourceInterface | ||||
|     { | ||||
|         return new class() extends AbstractSource { | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public function setUp(): void | ||||
|     { | ||||
|         $this->source = new UserSource(); | ||||
| @@ -75,7 +69,7 @@ class SourceMemberInformationTest extends TestCase | ||||
|     public function testError(): void | ||||
|     { | ||||
|         $this->expectException(\Error::class); | ||||
|         $this->source->getMemberRelation()->getMembers()->add($this->createSourceMock()); | ||||
|         $this->source->getMemberRelation()->getMembers()->add(new PureSource()); | ||||
|         $this->sourceMemberInformation->getAllMembers(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -5,8 +5,8 @@ namespace Tests\Unit\Domain\SourceManagement; | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use App\Entity\Source\SourceInterface; | ||||
| use App\Domain\SourceManagement\SourceMemberManagerInterface; | ||||
| use App\Entity\Source\AbstractSource; | ||||
| use App\Domain\SourceManagement\SourceMemberManager; | ||||
| use App\Entity\Source\PureSource; | ||||
|  | ||||
| class SourceMemberManagerTest extends TestCase | ||||
| { | ||||
| @@ -20,21 +20,15 @@ class SourceMemberManagerTest extends TestCase | ||||
|      */ | ||||
|     private $sourceMemberManager; | ||||
|  | ||||
|     private function createSource(): SourceInterface | ||||
|     { | ||||
|         return new class() extends AbstractSource { | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public function setUp(): void | ||||
|     { | ||||
|         $this->source = $this->createSource(); | ||||
|         $this->source = new PureSource(); | ||||
|         $this->sourceMemberManager = new SourceMemberManager($this->source); | ||||
|     } | ||||
|  | ||||
|     public function testAddAndRemoveMember(): void | ||||
|     { | ||||
|         $member = $this->createSource(); | ||||
|         $member = new PureSource(); | ||||
|         $this->assertNull($this->sourceMemberManager->addMember($member)); | ||||
|         $this->assertEquals($member, $this->source->getMemberRelation()->getMembers()->get(0)->getSource()); | ||||
|         $this->assertEquals($this->source, $member->getMemberRelation()->getMemberships()->get(0)->getSource()); | ||||
| @@ -45,7 +39,7 @@ class SourceMemberManagerTest extends TestCase | ||||
|  | ||||
|     public function testAddAndRemoveMembership(): void | ||||
|     { | ||||
|         $membership = $this->createSource(); | ||||
|         $membership = new PureSource(); | ||||
|         $this->assertNull($this->sourceMemberManager->addMembership($membership)); | ||||
|         $this->assertEquals($membership, $this->source->getMemberRelation()->getMemberships()->get(0)->getSource()); | ||||
|         $this->assertEquals($this->source, $membership->getMemberRelation()->getMembers()->get(0)->getSource()); | ||||
|   | ||||
| @@ -5,7 +5,6 @@ namespace Unit\Domain\SourceManagement; | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use App\Entity\Source\SourceInterface; | ||||
| use App\Domain\SourceManagement\SourceRightManagerInterface; | ||||
| use App\Entity\Source\AbstractSource; | ||||
| use App\Domain\SourceManagement\SourceRightManager; | ||||
| use App\Entity\Meta\RightInterface; | ||||
| use App\Entity\Meta\Right; | ||||
| @@ -13,6 +12,7 @@ use App\Entity\Meta\Law; | ||||
| use App\Exception\AllreadySetException; | ||||
| use App\Exception\NotSetException; | ||||
| use App\Exception\AllreadyDefinedException; | ||||
| use App\Entity\Source\PureSource; | ||||
|  | ||||
| class SourceRightManagerTest extends TestCase | ||||
| { | ||||
| @@ -31,15 +31,9 @@ class SourceRightManagerTest extends TestCase | ||||
|      */ | ||||
|     private $right; | ||||
|  | ||||
|     private function createSourceMock() | ||||
|     { | ||||
|         return new class() extends AbstractSource { | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public function setUp(): void | ||||
|     { | ||||
|         $this->source = $this->createSourceMock(); | ||||
|         $this->source = new PureSource(); | ||||
|         $this->sourceRightManager = new SourceRightManager($this->source); | ||||
|         $this->right = new Right(); | ||||
|     } | ||||
| @@ -53,7 +47,7 @@ class SourceRightManagerTest extends TestCase | ||||
|  | ||||
|     public function testSourceException(): void | ||||
|     { | ||||
|         $this->right->setSource($this->createSourceMock()); | ||||
|         $this->right->setSource(new PureSource()); | ||||
|         $this->expectException(AllreadyDefinedException::class); | ||||
|         $this->sourceRightManager->addRight($this->right); | ||||
|     } | ||||
|   | ||||
| @@ -6,9 +6,9 @@ use PHPUnit\Framework\TestCase; | ||||
| use App\Entity\Source\SourceInterface; | ||||
| use App\Entity\Meta\LawInterface; | ||||
| use Doctrine\Common\Collections\Collection; | ||||
| use App\Entity\Source\AbstractSource; | ||||
| use App\Entity\EntityInterface; | ||||
| use App\Entity\Meta\Relation\Parent\CreatorRelationInterface; | ||||
| use App\Entity\Source\PureSource; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
| @@ -20,15 +20,9 @@ class AbstractSourceTest extends TestCase | ||||
|      */ | ||||
|     protected $source; | ||||
|  | ||||
|     private function getSourceDummy(): SourceInterface | ||||
|     { | ||||
|         return new class() extends AbstractSource { | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public function setUp() | ||||
|     { | ||||
|         $this->source = $this->getSourceDummy(); | ||||
|         $this->source = new PureSource(); | ||||
|     } | ||||
|  | ||||
|     public function testConstructor(): void | ||||
|   | ||||
| @@ -5,9 +5,9 @@ namespace Tests\Unit\Entity\Source\Complex\Collection; | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use Doctrine\Common\Collections\Collection; | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use App\Entity\Source\AbstractSource; | ||||
| use App\Entity\Source\Complex\Collection\TreeCollectionSourceInterface; | ||||
| use App\Entity\Source\Complex\Collection\TreeCollectionSource; | ||||
| use App\Entity\Source\PureSource; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
| @@ -32,8 +32,7 @@ class TreeCollectionSourceTest extends TestCase | ||||
|  | ||||
|     public function testAccessors() | ||||
|     { | ||||
|         $member = new class() extends AbstractSource { | ||||
|         }; | ||||
|         $member = new PureSource(); | ||||
|         $this->tree->setCollection(new ArrayCollection([ | ||||
|             $member, | ||||
|         ])); | ||||
|   | ||||
| @@ -8,6 +8,9 @@ use App\Entity\Source\PureSource; | ||||
| use App\Entity\Source\AbstractSource; | ||||
| use PHPUnit\Framework\TestCase; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| class PureSourceTest extends TestCase | ||||
| { | ||||
|     /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user