mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 17:29:04 +00:00 
			
		
		
		
	Allowed guest users to access impressum
This commit is contained in:
		| @@ -9,36 +9,65 @@ use App\Entity\Source\Primitive\Text\TextSourceInterface; | ||||
| use App\DBAL\Types\SystemSlugType; | ||||
| use App\Entity\Source\Complex\UserSource; | ||||
| use App\Entity\Source\Complex\UserSourceInterface; | ||||
| use App\Entity\Meta\Right; | ||||
| use App\DBAL\Types\LayerType; | ||||
| use App\DBAL\Types\RightType; | ||||
| use App\Entity\Meta\RightInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  * | ||||
|  * @todo Create a collection class for all users | ||||
|  */ | ||||
| class SourceFixtures extends Fixture | ||||
| { | ||||
|     /** | ||||
|      * @var TextSourceInterface The example source for the impressum | ||||
|      */ | ||||
|     private $impressumSource; | ||||
|  | ||||
|     /** | ||||
|      * @var UserSourceInterface The UserSource which should be used for the anonymous user | ||||
|      */ | ||||
|     private $guestUserSource; | ||||
|  | ||||
|     public function load(ObjectManager $manager) | ||||
|     { | ||||
|         $manager->persist($this->getImpressum()); | ||||
|         $manager->persist($this->getGuestUser()); | ||||
|         $this->setGuestUserSource(); | ||||
|         $this->setImpressumSource(); | ||||
|         $manager->persist($this->impressumSource); | ||||
|         $manager->persist($this->getImpressumRight()); | ||||
|         $manager->persist($this->guestUserSource); | ||||
|         $manager->flush(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @return TextSourceInterface The example source for the impressum | ||||
|      */ | ||||
|     private function getImpressum(): TextSourceInterface | ||||
|     private function setImpressumSource(): void | ||||
|     { | ||||
|         $source = new TextSource(); | ||||
|         $source->setText('Example Impressum'); | ||||
|         $source->setSlug(SystemSlugType::IMPRINT); | ||||
|  | ||||
|         return $source; | ||||
|         $this->impressumSource = new TextSource(); | ||||
|         $this->impressumSource->setText('Example Impressum'); | ||||
|         $this->impressumSource->setSlug(SystemSlugType::IMPRINT); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @return UserSourceInterface The UserSource which should be used for the anonymous user | ||||
|      * @todo Implement that right gets automaticly created by persisting of law | ||||
|      * | ||||
|      * @return RightInterface | ||||
|      */ | ||||
|     private function getGuestUser(): UserSourceInterface | ||||
|     private function getImpressumRight(): RightInterface | ||||
|     { | ||||
|         $source = new UserSource(); | ||||
|         $source->setSlug(SystemSlugType::GUEST_USER); | ||||
|         $right = new Right(); | ||||
|         $right->setSource($this->impressumSource); | ||||
|         $right->setLaw($this->impressumSource->getLaw()); | ||||
|         $right->setLayer(LayerType::SOURCE); | ||||
|         $right->setType(RightType::READ); | ||||
|         $right->setReciever($this->guestUserSource); | ||||
|  | ||||
|         return $source; | ||||
|         return $right; | ||||
|     } | ||||
|  | ||||
|     private function setGuestUserSource(): void | ||||
|     { | ||||
|         $this->guestUserSource = new UserSource(); | ||||
|         $this->guestUserSource->setSlug(SystemSlugType::GUEST_USER); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -55,16 +55,16 @@ class SecureSourceLoaderTest extends KernelTestCase | ||||
|         $secureSourceLoader->getSource(); | ||||
|     } | ||||
|  | ||||
| //     public function testGranted(): void | ||||
| //     { | ||||
| //         $requestedSource = new TextSource(); | ||||
| //         $requestedSource->setSlug(SystemSlugType::IMPRINT); | ||||
| //         $requestedRight = new Right(); | ||||
| //         $requestedRight->setSource($requestedSource); | ||||
| //         $requestedRight->setLayer(LayerType::SOURCE); | ||||
| //         $requestedRight->setType(RightType::READ); | ||||
| //         $requestedRight->setReciever($this->sourceRepository->findOneBy(['slug' => SystemSlugType::GUEST_USER])); | ||||
| //         $secureSourceLoader = new SecureSourceLoader($this->sourceRepository, $requestedRight); | ||||
| //         $this->assertInstanceOf(TextSourceInterface::class, $secureSourceLoader->getSource()); | ||||
| //     } | ||||
|     public function testGranted(): void | ||||
|     { | ||||
|         $requestedSource = new TextSource(); | ||||
|         $requestedSource->setSlug(SystemSlugType::IMPRINT); | ||||
|         $requestedRight = new Right(); | ||||
|         $requestedRight->setSource($requestedSource); | ||||
|         $requestedRight->setLayer(LayerType::SOURCE); | ||||
|         $requestedRight->setType(RightType::READ); | ||||
|         $requestedRight->setReciever($this->sourceRepository->findOneBy(['slug' => SystemSlugType::GUEST_USER])); | ||||
|         $secureSourceLoader = new SecureSourceLoader($this->sourceRepository, $requestedRight); | ||||
|         $this->assertInstanceOf(TextSourceInterface::class, $secureSourceLoader->getSource()); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -67,9 +67,6 @@ class RightRepositoryTest extends KernelTestCase | ||||
|         $this->entityManager->persist($this->right); | ||||
|         $this->entityManager->flush(); | ||||
|         $rightId = $this->right->getId(); | ||||
|         /* | ||||
|          * @var RightInterface | ||||
|          */ | ||||
|         $this->loadedRight = $this->rightRepository->find($rightId); | ||||
|         $this->assertEquals($rightId, $this->loadedRight->getId()); | ||||
|         $this->assertEquals(self::PRIORITY, $this->loadedRight->getPriority()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user