entityManager = self::$container->get('doctrine.orm.default_entity_manager'); $this->setSourceRepository(); } private function setSourceRepository(): void { $this->sourceRepository = $this->entityManager->getRepository(AbstractSource::class); } public function testAccessDeniedException(): void { $requestedSource = new TextSource(); $requestedSource->setSlug(SystemSlugType::IMPRINT); $requestedRight = new Right(); $requestedRight->setSource($requestedSource); $requestedRight->setLayer(LayerType::SOURCE); $requestedRight->setType(RightType::READ); $requestedRight->setReciever(new UserSource()); $secureSourceLoader = new SecureSourceLoader($this->entityManager, $requestedRight); $this->expectException(AccessDeniedHttpException::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->entityManager, $requestedRight); $this->assertInstanceOf(TextSourceInterface::class, $secureSourceLoader->getSource()); } }