setSourceRepository($kernel); } private function setSourceRepository(KernelInterface $kernel): void { $this->sourceRepository = $kernel->getContainer() ->get('doctrine') ->getManager()->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->sourceRepository, $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->sourceRepository, $requestedRight); // $this->assertInstanceOf(TextSourceInterface::class, $secureSourceLoader->getSource()); // } }