get('request_stack'); $security = new Security(self::$kernel->getContainer()); $entityManager = self::$container->get('doctrine.orm.default_entity_manager'); $this->secureSourceReadService = new SecureSourceReadService($requestStack, $security, $entityManager); } public function testAccessDeniedException(): void { $requestedSource = new TextSource(); $requestedSource->setSlug(SystemSlugType::IMPRINT); $requestedRight = new Right(); $requestedRight->setSource($requestedSource); $requestedRight->setLayer(LayerType::SOURCE); $requestedRight->setCrud(CRUDType::READ); $requestedRight->setReciever(new UserSource()); $this->expectException(AccessDeniedHttpException::class); $this->secureSourceReadService->read($requestedRight); } public function testGranted(): void { $requestedSource = new TextSource(); $requestedSource->setSlug(SystemSlugType::IMPRINT); $requestedRight = new Right(); $requestedRight->setSource($requestedSource); $requestedRight->setLayer(LayerType::SOURCE); $requestedRight->setCrud(CRUDType::READ); $requestedRight->setReciever($this->sourceRepository->findOneBySlug(SystemSlugType::GUEST_USER)); $textSourceResponse = $this->secureSourceReadService->read($requestedRight); $this->assertInstanceOf(TextSourceInterface::class, $textSourceResponse); } }