mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 03:07:58 +00:00 
			
		
		
		
	Optimized RequestManagement and tests
This commit is contained in:
		@@ -6,6 +6,8 @@ use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @author kevinfrantz
 | 
					 * @author kevinfrantz
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @see RequestedEntityAttributInterface
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
trait RequestedEntityAttribut
 | 
					trait RequestedEntityAttribut
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -29,4 +31,12 @@ trait RequestedEntityAttribut
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->requestedEntity = $requestedEntity;
 | 
					        $this->requestedEntity = $requestedEntity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @return bool
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function hasRequestedEntity(): bool
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return isset($this->requestedEntity);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,11 @@ use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
interface RequestedEntityAttributInterface
 | 
					interface RequestedEntityAttributInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @return bool
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function hasRequestedEntity(): bool;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return RequestedEntityInterface
 | 
					     * @return RequestedEntityInterface
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,14 @@ trait RequestedRightAttribut
 | 
				
			|||||||
        $this->requestedRight = $requestedRight;
 | 
					        $this->requestedRight = $requestedRight;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @return bool
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function hasRequestedRight(): bool
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return isset($this->requestedRight);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return RequestedRightInterface
 | 
					     * @return RequestedRightInterface
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,11 @@ use App\Domain\RequestManagement\Right\RequestedRightInterface;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
interface RequestedRightAttributInterface
 | 
					interface RequestedRightAttributInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @return bool
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function hasRequestedRight(): bool;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @param RequestedRightInterface $requestedRight
 | 
					     * @param RequestedRightInterface $requestedRight
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,7 @@ use App\Entity\Source\AbstractSource;
 | 
				
			|||||||
use App\Exception\NotSetException;
 | 
					use App\Exception\NotSetException;
 | 
				
			||||||
use App\Repository\RepositoryInterface;
 | 
					use App\Repository\RepositoryInterface;
 | 
				
			||||||
use App\Entity\Source\SourceInterface;
 | 
					use App\Entity\Source\SourceInterface;
 | 
				
			||||||
 | 
					use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @author kevinfrantz
 | 
					 * @author kevinfrantz
 | 
				
			||||||
@@ -53,19 +54,44 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
					     * @throws NotSetException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private function validateHasIdentity(): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (!($this->hasId() || $this->hasSlug())) {
 | 
				
			||||||
 | 
					            throw new NotSetException('No identity attribut like id or slug was set!');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @param EntityInterface|null $entity
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @throws NotFoundHttpException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private function validateLoadedEntity(?EntityInterface $entity): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (!$entity) {
 | 
				
			||||||
 | 
					            throw new NotFoundHttpException('Entity with {id:"'.$this->id.'",slug:"'.$this->slug.'"} not found');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Sorry for the messed function, but should work ;)
 | 
				
			||||||
     * {@inheritdoc}
 | 
					     * {@inheritdoc}
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @see \App\Domain\RequestManagement\Entity\RequestedEntityInterface::getEntity()
 | 
					     * @see \App\Domain\RequestManagement\Entity\RequestedEntityInterface::getEntity()
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function getEntity(): EntityInterface
 | 
					    public function getEntity(): EntityInterface
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        $this->validateHasIdentity();
 | 
				
			||||||
        if ($this->hasSlug()) {
 | 
					        if ($this->hasSlug()) {
 | 
				
			||||||
            return $this->loadBySlug();
 | 
					            $entity = $this->loadBySlug();
 | 
				
			||||||
 | 
					        } elseif ($this->hasId()) {
 | 
				
			||||||
 | 
					            $entity = $this->loadById();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if ($this->hasId()) {
 | 
					        $this->validateLoadedEntity($entity);
 | 
				
			||||||
            return $this->loadById();
 | 
					
 | 
				
			||||||
        }
 | 
					        return $entity;
 | 
				
			||||||
        throw new NotSetException('No identity attribut like id or slug was set!');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -82,9 +108,9 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @throws NotCorrectInstanceException
 | 
					     * @throws NotCorrectInstanceException
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return SourceInterface
 | 
					     * @return SourceInterface|null
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private function loadBySlug(): SourceInterface
 | 
					    private function loadBySlug(): ?SourceInterface
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $repository = $this->getEntityRepository();
 | 
					        $repository = $this->getEntityRepository();
 | 
				
			||||||
        if ($repository instanceof SourceRepositoryInterface) {
 | 
					        if ($repository instanceof SourceRepositoryInterface) {
 | 
				
			||||||
@@ -94,9 +120,9 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return EntityInterface
 | 
					     * @return EntityInterface|null
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private function loadById(): EntityInterface
 | 
					    private function loadById(): ?EntityInterface
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $repository = $this->getEntityRepository();
 | 
					        $repository = $this->getEntityRepository();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -112,7 +138,7 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
 | 
				
			|||||||
    public function setRequestedRight($requestedRight): void
 | 
					    public function setRequestedRight($requestedRight): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->requestedRight = $requestedRight;
 | 
					        $this->requestedRight = $requestedRight;
 | 
				
			||||||
        if ($this->requestedRight !== $this) {
 | 
					        if (!$this->requestedRight->hasRequestedEntity()) {
 | 
				
			||||||
            $this->requestedRight->setRequestedEntity($this);
 | 
					            $this->requestedRight->setRequestedEntity($this);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -114,4 +114,14 @@ abstract class AbstractRequestedRightFacade implements RequestedRightInterface
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->requestedRight->setReciever($reciever);
 | 
					        $this->requestedRight->setReciever($reciever);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * {@inheritdoc}
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @see \App\Attribut\RequestedEntityAttributInterface::hasRequestedEntity()
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function hasRequestedEntity(): bool
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->requestedRight->hasRequestedEntity();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,11 +27,6 @@ class RequestedRight implements RequestedRightInterface
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private $source;
 | 
					    private $source;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * @var RequestedEntityInterface
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private $requestedEntity;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @throws NotCorrectInstanceException
 | 
					     * @throws NotCorrectInstanceException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -40,11 +35,15 @@ class RequestedRight implements RequestedRightInterface
 | 
				
			|||||||
        $entity = $this->requestedEntity->getEntity();
 | 
					        $entity = $this->requestedEntity->getEntity();
 | 
				
			||||||
        if ($entity instanceof SourceInterface) {
 | 
					        if ($entity instanceof SourceInterface) {
 | 
				
			||||||
            $this->source = $entity;
 | 
					            $this->source = $entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if ($entity instanceof MetaInterface) {
 | 
					        if ($entity instanceof MetaInterface) {
 | 
				
			||||||
            $this->source = $entity->getSource();
 | 
					            $this->source = $entity->getSource();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        throw new NotCorrectInstanceException('The entity instance can\'t be processed');
 | 
					        throw new NotCorrectInstanceException('The entity instance '.get_class($entity).' can\'t be processed');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -92,7 +91,7 @@ class RequestedRight implements RequestedRightInterface
 | 
				
			|||||||
    final public function setRequestedEntity(RequestedEntityInterface $requestedEntity): void
 | 
					    final public function setRequestedEntity(RequestedEntityInterface $requestedEntity): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->requestedEntity = $requestedEntity;
 | 
					        $this->requestedEntity = $requestedEntity;
 | 
				
			||||||
        if ($requestedEntity->getRequestedRight() !== $this) {
 | 
					        if (!$requestedEntity->hasRequestedRight()) {
 | 
				
			||||||
            $this->requestedEntity->setRequestedRight($this);
 | 
					            $this->requestedEntity->setRequestedRight($this);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,9 @@ use App\Attribut\RightAttributInterface;
 | 
				
			|||||||
use App\Attribut\RightAttribut;
 | 
					use App\Attribut\RightAttribut;
 | 
				
			||||||
use App\Entity\Meta\RightInterface;
 | 
					use App\Entity\Meta\RightInterface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @author kevinfrantz
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
class RightAttributTest extends TestCase
 | 
					class RightAttributTest extends TestCase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /***
 | 
					    /***
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@ use App\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
 | 
				
			|||||||
use App\Domain\RepositoryManagement\LayerRepositoryFactoryService;
 | 
					use App\Domain\RepositoryManagement\LayerRepositoryFactoryService;
 | 
				
			||||||
use App\Repository\RepositoryInterface;
 | 
					use App\Repository\RepositoryInterface;
 | 
				
			||||||
use App\Exception\NotSetException;
 | 
					use App\Exception\NotSetException;
 | 
				
			||||||
 | 
					use App\Domain\LayerManagement\LayerClassMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @author kevinfrantz
 | 
					 * @author kevinfrantz
 | 
				
			||||||
@@ -27,7 +28,7 @@ class LayerRepositoryFactoryServiceTest extends KernelTestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function testGetRepository(): void
 | 
					    public function testGetRepository(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        foreach (array_keys(LayerRepositoryFactoryService::LAYER_CLASS_MAP) as $layer) {
 | 
					        foreach (array_keys(LayerClassMap::LAYER_CLASS_MAP) as $layer) {
 | 
				
			||||||
            $repositoy = $this->layerRepositoryFactoryService->getRepository($layer);
 | 
					            $repositoy = $this->layerRepositoryFactoryService->getRepository($layer);
 | 
				
			||||||
            $this->assertInstanceOf(RepositoryInterface::class, $repositoy);
 | 
					            $this->assertInstanceOf(RepositoryInterface::class, $repositoy);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@ namespace tests\Unit\Domain\RequestManagement\Entity;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use PHPUnit\Framework\TestCase;
 | 
					use PHPUnit\Framework\TestCase;
 | 
				
			||||||
use App\Domain\RequestManagement\Entity\RequestedEntity;
 | 
					use App\Domain\RequestManagement\Entity\RequestedEntity;
 | 
				
			||||||
 | 
					use App\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @author kevinfrantz
 | 
					 * @author kevinfrantz
 | 
				
			||||||
@@ -12,7 +13,8 @@ class RequestedEntityTest extends TestCase
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public function testSetByIdentity(): void
 | 
					    public function testSetByIdentity(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $requestedEntity = new RequestedEntity();
 | 
					        $layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
 | 
				
			||||||
 | 
					        $requestedEntity = new RequestedEntity($layerRepositoryFactoryService);
 | 
				
			||||||
        $slug = 'test';
 | 
					        $slug = 'test';
 | 
				
			||||||
        $requestedEntity->setIdentity($slug);
 | 
					        $requestedEntity->setIdentity($slug);
 | 
				
			||||||
        $this->assertEquals($slug, $requestedEntity->getSlug());
 | 
					        $this->assertEquals($slug, $requestedEntity->getSlug());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,13 +5,15 @@ namespace tests\Unit\Domain\RequestManagement\Entity;
 | 
				
			|||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
 | 
					use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
 | 
				
			||||||
use App\Domain\RequestManagement\Right\RequestedRightInterface;
 | 
					use App\Domain\RequestManagement\Right\RequestedRightInterface;
 | 
				
			||||||
use App\Domain\RequestManagement\Right\RequestedRight;
 | 
					use App\Domain\RequestManagement\Right\RequestedRight;
 | 
				
			||||||
use App\Entity\Source\AbstractSource;
 | 
					 | 
				
			||||||
use App\DBAL\Types\Meta\Right\LayerType;
 | 
					use App\DBAL\Types\Meta\Right\LayerType;
 | 
				
			||||||
use App\Domain\RequestManagement\Entity\RequestedEntity;
 | 
					use App\Domain\RequestManagement\Entity\RequestedEntity;
 | 
				
			||||||
use App\DBAL\Types\SystemSlugType;
 | 
					use App\DBAL\Types\SystemSlugType;
 | 
				
			||||||
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
 | 
					use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
 | 
				
			||||||
use App\Exception\PreconditionFailedException;
 | 
					use App\Exception\PreconditionFailedException;
 | 
				
			||||||
use App\Exception\NotSetException;
 | 
					use App\Entity\Source\PureSource;
 | 
				
			||||||
 | 
					use App\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
 | 
				
			||||||
 | 
					use App\Domain\RepositoryManagement\LayerRepositoryFactoryService;
 | 
				
			||||||
 | 
					use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @author kevinfrantz
 | 
					 * @author kevinfrantz
 | 
				
			||||||
@@ -23,12 +25,17 @@ class RequestedRightTest extends KernelTestCase
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private $requestedRight;
 | 
					    private $requestedRight;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @var LayerRepositoryFactoryServiceInterface
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private $layerRepositoryFactoryService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function setUp(): void
 | 
					    public function setUp(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        self::bootKernel();
 | 
					        self::bootKernel();
 | 
				
			||||||
        $entityManager = self::$container->get('doctrine.orm.default_entity_manager');
 | 
					        $entityManager = self::$container->get('doctrine.orm.default_entity_manager');
 | 
				
			||||||
        $sourceRepository = $entityManager->getRepository(AbstractSource::class);
 | 
					        $this->layerRepositoryFactoryService = new LayerRepositoryFactoryService($entityManager);
 | 
				
			||||||
        $this->requestedRight = new RequestedRight($sourceRepository);
 | 
					        $this->requestedRight = new RequestedRight();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function testLayer(): void
 | 
					    public function testLayer(): void
 | 
				
			||||||
@@ -54,24 +61,27 @@ class RequestedRightTest extends KernelTestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function testKnownSource(): void
 | 
					    public function testKnownSource(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $requestedSource = new RequestedEntity();
 | 
					        $requestedEntity = new RequestedEntity($this->layerRepositoryFactoryService);
 | 
				
			||||||
        $requestedSource->setSlug(SystemSlugType::IMPRINT);
 | 
					        $requestedEntity->setSlug(SystemSlugType::IMPRINT);
 | 
				
			||||||
        $this->requestedRight->setRequestedEntity($requestedSource);
 | 
					        $this->requestedRight->setRequestedEntity($requestedEntity);
 | 
				
			||||||
 | 
					        $this->requestedRight->setLayer(LayerType::SOURCE);
 | 
				
			||||||
        $sourceResponse1 = $this->requestedRight->getSource();
 | 
					        $sourceResponse1 = $this->requestedRight->getSource();
 | 
				
			||||||
        $this->assertGreaterThan(0, $sourceResponse1->getId());
 | 
					        $this->assertGreaterThan(0, $sourceResponse1->getId());
 | 
				
			||||||
        $requestedSource->setSlug('');
 | 
					        $requestedEntity->setSlug('');
 | 
				
			||||||
        $this->expectException(NotSetException::class);
 | 
					        $this->expectException(NotFoundHttpException::class);
 | 
				
			||||||
        $this->requestedRight->getSource();
 | 
					        $this->requestedRight->getSource();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function testEqualsSlug(): void
 | 
					    public function testEqualsSlug(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $slug = SystemSlugType::IMPRINT;
 | 
					        $slug = SystemSlugType::IMPRINT;
 | 
				
			||||||
        $requestedSource = $this->createMock(RequestedEntityInterface::class);
 | 
					        $requestedEntityEntity = new PureSource();
 | 
				
			||||||
        $requestedSource->method('getSlug')->willReturn($slug);
 | 
					        $requestedEntity = $this->createMock(RequestedEntityInterface::class);
 | 
				
			||||||
        $requestedSource->method('hasSlug')->willReturn(true);
 | 
					        $requestedEntity->method('getSlug')->willReturn($slug);
 | 
				
			||||||
        $this->assertEquals($slug, $requestedSource->getSlug());
 | 
					        $requestedEntity->method('hasSlug')->willReturn(true);
 | 
				
			||||||
        $this->requestedRight->setRequestedEntity($requestedSource);
 | 
					        $requestedEntity->method('getEntity')->willReturn($requestedEntityEntity);
 | 
				
			||||||
 | 
					        $this->assertEquals($slug, $requestedEntity->getSlug());
 | 
				
			||||||
 | 
					        $this->requestedRight->setRequestedEntity($requestedEntity);
 | 
				
			||||||
        $responseSource1 = $this->requestedRight->getSource();
 | 
					        $responseSource1 = $this->requestedRight->getSource();
 | 
				
			||||||
        $responseSource2 = $this->requestedRight->getSource();
 | 
					        $responseSource2 = $this->requestedRight->getSource();
 | 
				
			||||||
        $this->assertEquals($responseSource1, $responseSource2);
 | 
					        $this->assertEquals($responseSource1, $responseSource2);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,8 +15,8 @@ use App\Domain\UserManagement\UserSourceDirector;
 | 
				
			|||||||
use App\Repository\Source\SourceRepositoryInterface;
 | 
					use App\Repository\Source\SourceRepositoryInterface;
 | 
				
			||||||
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
 | 
					use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
 | 
				
			||||||
use App\DBAL\Types\SystemSlugType;
 | 
					use App\DBAL\Types\SystemSlugType;
 | 
				
			||||||
use App\Exception\NotSetException;
 | 
					 | 
				
			||||||
use App\Exception\SetNotPossibleException;
 | 
					use App\Exception\SetNotPossibleException;
 | 
				
			||||||
 | 
					use App\Exception\NotCorrectInstanceException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @author kevinfrantz
 | 
					 * @author kevinfrantz
 | 
				
			||||||
@@ -61,7 +61,7 @@ class RequestedUserTest extends TestCase
 | 
				
			|||||||
        $requestedSource->method('getSlug')->willReturn(SystemSlugType::IMPRINT);
 | 
					        $requestedSource->method('getSlug')->willReturn(SystemSlugType::IMPRINT);
 | 
				
			||||||
        $requestedSource->method('hasSlug')->willReturn(true);
 | 
					        $requestedSource->method('hasSlug')->willReturn(true);
 | 
				
			||||||
        $sourceRepository = $this->createMock(SourceRepositoryInterface::class);
 | 
					        $sourceRepository = $this->createMock(SourceRepositoryInterface::class);
 | 
				
			||||||
        $requestedRight = new RequestedRight($sourceRepository);
 | 
					        $requestedRight = new RequestedRight();
 | 
				
			||||||
        $user = $this->createMock(User::class);
 | 
					        $user = $this->createMock(User::class);
 | 
				
			||||||
        $userSourceDirector = new UserSourceDirector($sourceRepository, $user);
 | 
					        $userSourceDirector = new UserSourceDirector($sourceRepository, $user);
 | 
				
			||||||
        $requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
 | 
					        $requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
 | 
				
			||||||
@@ -70,7 +70,7 @@ class RequestedUserTest extends TestCase
 | 
				
			|||||||
        $this->assertNull($requestedUserRightFacade->setRequestedEntity($requestedSource));
 | 
					        $this->assertNull($requestedUserRightFacade->setRequestedEntity($requestedSource));
 | 
				
			||||||
        $this->assertEquals($layer, $requestedRight->getLayer());
 | 
					        $this->assertEquals($layer, $requestedRight->getLayer());
 | 
				
			||||||
        $this->assertEquals($type, $requestedRight->getCrud());
 | 
					        $this->assertEquals($type, $requestedRight->getCrud());
 | 
				
			||||||
        $this->expectException(NotSetException::class);
 | 
					        $this->expectException(NotCorrectInstanceException::class);
 | 
				
			||||||
        $this->assertNotInstanceOf(RequestedEntityInterface::class, $requestedRight->getSource());
 | 
					        $this->assertNotInstanceOf(RequestedEntityInterface::class, $requestedRight->getSource());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user