Renamed domain RequestManagement to Request

This commit is contained in:
Kevin Frantz
2019-05-30 16:52:02 +02:00
parent 9af7f47b85
commit b8029bb7cc
75 changed files with 149 additions and 149 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace tests\Unit\Domain\Request\Action;
use PHPUnit\Framework\TestCase;
use Infinito\Domain\Request\Action\RequestedActionService;
use Infinito\Domain\Request\Action\RequestedActionServiceInterface;
use Infinito\Domain\Request\User\RequestedUserServiceInterface;
use Infinito\Domain\UserManagement\UserSourceDirectorInterface;
/**
* @author kevinfrantz
*/
class RequestedActionServiceTest extends TestCase
{
public function testConstructorSet(): void
{
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
$requestedUserService = $this->createMock(RequestedUserServiceInterface::class);
$requestedUserService->method('getUserSourceDirector')->willReturn($userSourceDirector);
$service = new RequestedActionService($requestedUserService);
$this->assertInstanceOf(RequestedActionServiceInterface::class, $service);
}
}

View File

@@ -0,0 +1,82 @@
<?php
namespace tests\Unit\Domain\Request\Action;
use PHPUnit\Framework\TestCase;
use Infinito\Domain\Request\Right\RequestedRightInterface;
use Infinito\Domain\Request\Action\RequestedActionInterface;
use Infinito\Domain\Request\Right\RequestedRight;
use Infinito\Domain\Request\Action\RequestedAction;
use Infinito\DBAL\Types\ActionType;
use Infinito\Repository\Source\SourceRepositoryInterface;
use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Domain\UserManagement\UserSourceDirector;
use Infinito\Domain\Request\User\RequestedUser;
use Infinito\Entity\Source\Complex\UserSourceInterface;
/**
* @author kevinfrantz
*/
class RequestedActionTest extends TestCase
{
/**
* @var RequestedRightInterface
*/
private $requestedRight;
/**
* @var RequestedActionInterface
*/
private $action;
/**
* {@inheritdoc}
*
* @see \PHPUnit\Framework\TestCase::setUp()
*/
public function setUp(): void
{
$userSource = $this->createMock(UserSourceInterface::class);
$sourceRepository = $this->createMock(SourceRepositoryInterface::class);
$sourceRepository->method('findOneBySlug')->willReturn($userSource);
$user = null;
$userSourceDirector = new UserSourceDirector($sourceRepository, $user);
$requestedRight = new RequestedRight();
$this->requestedRight = new RequestedUser($userSourceDirector, $requestedRight);
$this->action = new RequestedAction($this->requestedRight);
}
public function testList(): void
{
$list = ActionType::EXECUTE;
$this->action->setActionType($list);
$this->assertEquals($list, $this->action->getActionType());
$this->assertEquals(ActionType::EXECUTE, $this->requestedRight->getActionType());
}
public function testCrud(): void
{
foreach (ActionType::getValues() as $crud) {
$userSource = $this->createMock(UserSourceInterface::class);
$sourceRepository = $this->createMock(SourceRepositoryInterface::class);
$sourceRepository->method('findOneBySlug')->willReturn($userSource);
$user = null;
$userSourceDirector = new UserSourceDirector($sourceRepository, $user);
$requestedRight = new RequestedRight();
$this->requestedRight = new RequestedUser($userSourceDirector, $requestedRight);
$this->action = new RequestedAction($this->requestedRight);
$this->action->setActionType($crud);
$this->assertEquals($crud, $this->action->getActionType());
$this->assertEquals($crud, $this->requestedRight->getActionType());
}
}
public function testLayer(): void
{
foreach (LayerType::getValues() as $LayerType) {
$this->action->setLayer($LayerType);
$this->assertEquals($LayerType, $this->action->getLayer());
$this->assertEquals($LayerType, $this->requestedRight->getLayer());
}
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace tests\Unit\Domain\Request\Entity;
use PHPUnit\Framework\TestCase;
use Infinito\Domain\Request\Entity\RequestedEntityInterface;
use Infinito\Domain\Request\Entity\LazyRequestedEntity;
use Infinito\Domain\Repository\LayerRepositoryFactoryServiceInterface;
use Infinito\Repository\RepositoryInterface;
use Infinito\Entity\Source\PureSource;
use Infinito\Repository\Source\SourceRepositoryInterface;
use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Domain\Request\Right\RequestedRightInterface;
class LazyRequestedEntityTest extends TestCase
{
/**
* @var RequestedEntityInterface
*/
private $lazyRequestedEntity;
/**
* @var LayerRepositoryFactoryServiceInterface
*/
private $layerRepositoryFactoryService;
/**
* @var SourceRepositoryInterface
*/
private $repository;
/**
* {@inheritdoc}
*
* @see \PHPUnit\Framework\TestCase::setUp()
*/
public function setUp(): void
{
$this->repository = $this->createMock(SourceRepositoryInterface::class);
$this->layerRepositoryFactoryService = new class($this->repository) implements LayerRepositoryFactoryServiceInterface {
private $count = 0;
private $repository;
public function __construct($repository)
{
$this->repository = $repository;
}
public function getRepository(string $layer): RepositoryInterface
{
if ($this->count > 0) {
//Just for information and testing thrown
throw new \Exception('The function '.__FUNCTION__.' was called multiple times!');
}
++$this->count;
return $this->repository;
}
};
$this->lazyRequestedEntity = new LazyRequestedEntity($this->layerRepositoryFactoryService);
}
public function testSlug(): void
{
$slug = 'hello';
$requestedSource = new PureSource();
$requestedSource->setSlug($slug);
$requestedSource->setId('123');
$this->repository->method('findOneBySlug')->willReturn($requestedSource);
$requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedRight->method('getLayer')->willReturn(LayerType::SOURCE);
$this->assertNull($this->lazyRequestedEntity->setRequestedRight($requestedRight));
$this->assertNull($this->lazyRequestedEntity->setSlug($slug));
//Call 1
$this->assertEquals($requestedSource, $this->lazyRequestedEntity->getEntity());
//Call 2
$this->assertEquals($requestedSource, $this->lazyRequestedEntity->getEntity());
//Call with other slug
$this->assertNull($this->lazyRequestedEntity->setSlug('abcde'));
$this->expectException(\Exception::class);
$this->lazyRequestedEntity->getEntity();
}
public function testId(): void
{
$id = 12345;
$requestedSource = new PureSource();
$requestedSource->setId($id);
$this->repository->method('find')->willReturn($requestedSource);
$requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedRight->method('getLayer')->willReturn(LayerType::SOURCE);
$this->assertNull($this->lazyRequestedEntity->setRequestedRight($requestedRight));
$this->assertNull($this->lazyRequestedEntity->setId($id));
//Call 1
$this->assertEquals($requestedSource, $this->lazyRequestedEntity->getEntity());
//Call 2
$this->assertEquals($requestedSource, $this->lazyRequestedEntity->getEntity());
//Call with other slug
$this->assertNull($this->lazyRequestedEntity->setId(65432));
$this->expectException(\Exception::class);
$this->lazyRequestedEntity->getEntity();
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace tests\Unit\Domain\Request\Entity;
use PHPUnit\Framework\TestCase;
use Infinito\Domain\Request\Entity\RequestedEntity;
use Infinito\Domain\Repository\LayerRepositoryFactoryServiceInterface;
use Infinito\Domain\Request\Right\RequestedRightInterface;
use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Repository\RepositoryInterface;
use Infinito\Entity\EntityInterface;
use Infinito\Entity\Source\AbstractSource;
use Infinito\Exception\Attribut\UndefinedAttributException;
use Infinito\Exception\Core\NoIdentityCoreException;
use Infinito\Exception\Attribut\AllreadyDefinedAttributException;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
/**
* @author kevinfrantz
*/
class RequestedEntityTest extends TestCase
{
public function testSetByIdentity(): void
{
$layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
$requestedEntity = new RequestedEntity($layerRepositoryFactoryService);
$slug = 'test';
$requestedEntity->setIdentity($slug);
$this->assertEquals($slug, $requestedEntity->getSlug());
$this->assertFalse($requestedEntity->hasId());
$id = 123;
$requestedEntity->setIdentity($id);
$this->assertEquals($id, $requestedEntity->getId());
$this->assertFalse($requestedEntity->hasSlug());
}
public function testNotSetExeptionIdSlug(): void
{
$layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
$requestedEntity = new RequestedEntity($layerRepositoryFactoryService);
$this->expectException(NoIdentityCoreException::class);
$requestedEntity->getEntity();
}
public function testNotCorrectInstanceException(): void
{
$layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
$layerRepositoryFactoryService->method('getRepository')->willReturn($this->createMock(RepositoryInterface::class));
$requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedRight->method('getLayer')->willReturn(LayerType::LAW);
$requestedEntity = new RequestedEntity($layerRepositoryFactoryService);
$requestedEntity->setSlug('abcd');
$requestedEntity->setRequestedRight($requestedRight);
$this->expectException(NotCorrectInstanceCoreException::class);
$requestedEntity->getEntity();
}
public function testLoadById(): void
{
$entityMock = $this->createMock(EntityInterface::class);
$repository = $this->createMock(RepositoryInterface::class);
$repository->method('find')->willReturn($entityMock);
$layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
$layerRepositoryFactoryService->method('getRepository')->willReturn($repository);
$requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedRight->method('getLayer')->willReturn(LayerType::LAW);
$requestedEntity = new RequestedEntity($layerRepositoryFactoryService);
$requestedEntity->setId(123);
$requestedEntity->setRequestedRight($requestedRight);
$entityResult = $requestedEntity->getEntity();
$this->assertEquals($entityMock, $entityResult);
$this->assertEquals(get_class($entityMock), $requestedEntity->getClass());
$this->expectException(AllreadyDefinedAttributException::class);
$requestedEntity->setClass(AbstractSource::class);
}
public function testSetClass(): void
{
$class = AbstractSource::class;
$entityMock = $this->createMock(EntityInterface::class);
$repository = $this->createMock(RepositoryInterface::class);
$repository->method('find')->willReturn($entityMock);
$layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
$layerRepositoryFactoryService->method('getRepository')->willReturn($repository);
$requestedEntity = new RequestedEntity($layerRepositoryFactoryService);
$this->assertFalse($requestedEntity->hasClass());
$this->assertNull($requestedEntity->setClass($class));
$this->assertTrue($requestedEntity->hasClass());
$this->assertEquals($class, $requestedEntity->getClass());
$this->expectException(AllreadyDefinedAttributException::class);
$requestedEntity->setIdentity('123343');
}
public function testValidateLayerRepositoryFactoryService(): void
{
$requestedEntity = new RequestedEntity();
$requestedEntity->setSlug('ABABEBA');
$this->expectException(UndefinedAttributException::class);
$requestedEntity->getEntity();
}
}

View File

@@ -0,0 +1,94 @@
<?php
namespace tests\Unit\Domain\RightManagement\User;
use PHPUnit\Framework\TestCase;
use Infinito\Entity\User;
use Infinito\Domain\Request\User\RequestedUser;
use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\DBAL\Types\Meta\Right\CRUDType;
use Infinito\Entity\Source\AbstractSource;
use Infinito\Domain\UserManagement\UserSourceDirectorInterface;
use Infinito\Domain\Request\Right\RequestedRightInterface;
use Infinito\Domain\Request\Right\RequestedRight;
use Infinito\Domain\Request\Entity\RequestedEntityInterface;
use Infinito\Entity\Source\SourceInterface;
use Infinito\Domain\Request\Right\AbstractRequestedRightFacade;
use Infinito\Domain\Fixture\FixtureSource\ImpressumFixtureSource;
use Infinito\Exception\Collection\NotPossibleSetElementException;
/**
* @author kevinfrantz
*/
class AbstractRequestedRightFacadeTest extends TestCase
{
/**
* @param RequestedRightInterface $requestedRight
*
* @return AbstractRequestedRightFacade
*/
private function getRequestedRightFacade(RequestedRightInterface $requestedRight): AbstractRequestedRightFacade
{
return new class($requestedRight) extends AbstractRequestedRightFacade {
};
}
public function testGetters(): void
{
$reciever = $this->createMock(AbstractSource::class);
$user = $this->createMock(User::class);
$user->method('getSource')->willReturn($reciever);
$layer = LayerType::SOURCE;
$type = CRUDType::READ;
$requestedEntity = $this->createMock(RequestedEntityInterface::class);
$source = $this->createMock(AbstractSource::class);
$reciever = $this->createMock(AbstractSource::class);
$requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedRight->method('getLayer')->willReturn($layer);
$requestedRight->method('getActionType')->willReturn($type);
$requestedRight->method('getSource')->willReturn($source);
$requestedRight->method('getReciever')->willReturn($reciever);
$requestedRight->method('getRequestedEntity')->willReturn($requestedEntity);
$requestedRight->method('hasRequestedEntity')->willReturn(true);
$requestedRight->method('hasReciever')->willReturn(true);
$requestedRightFacade = $this->getRequestedRightFacade($requestedRight);
$this->assertEquals($layer, $requestedRightFacade->getLayer());
$this->assertEquals($type, $requestedRightFacade->getActionType());
$this->assertEquals($source, $requestedRightFacade->getSource());
$this->assertEquals($reciever, $requestedRightFacade->getReciever());
$this->assertEquals($requestedEntity, $requestedRightFacade->getRequestedEntity());
$this->assertTrue($requestedRightFacade->hasRequestedEntity());
$this->assertTrue($requestedRightFacade->hasReciever());
}
public function testSetters(): void
{
$layer = LayerType::SOURCE;
$type = CRUDType::READ;
$reciever = $this->createMock(SourceInterface::class);
$requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('getSlug')->willReturn(ImpressumFixtureSource::getSlug());
$requestedEntity->method('hasSlug')->willReturn(true);
$requestedRight = new RequestedRight();
$requestedRightFacade = $this->getRequestedRightFacade($requestedRight);
$this->assertNull($requestedRightFacade->setLayer($layer));
$this->assertNull($requestedRightFacade->setActionType($type));
$this->assertNull($requestedRightFacade->setRequestedEntity($requestedEntity));
$this->assertNull($requestedRightFacade->setReciever($reciever));
$this->assertEquals($layer, $requestedRight->getLayer());
$this->assertEquals($type, $requestedRight->getActionType());
$this->assertEquals($requestedEntity, $requestedRight->getRequestedEntity());
$this->assertEquals($reciever, $requestedRight->getReciever());
$this->assertTrue($requestedRight->hasReciever());
}
public function testSetReciever(): void
{
$reciever = $this->createMock(AbstractSource::class);
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
$requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
$this->expectException(NotPossibleSetElementException::class);
$requestedUserRightFacade->setReciever($reciever);
}
}

View File

@@ -0,0 +1,121 @@
<?php
namespace tests\Unit\Domain\Request\Right;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Infinito\Domain\Request\Right\RequestedRightInterface;
use Infinito\Domain\Request\Right\RequestedRight;
use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Domain\Request\Entity\RequestedEntity;
use Infinito\Domain\Request\Entity\RequestedEntityInterface;
use Infinito\Entity\Source\PureSource;
use Infinito\Domain\Repository\LayerRepositoryFactoryServiceInterface;
use Infinito\Domain\Repository\LayerRepositoryFactoryService;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Infinito\Entity\Meta\Law;
use Infinito\Entity\Source\SourceInterface;
use Infinito\DBAL\Types\ActionType;
use Infinito\Domain\Fixture\FixtureSource\ImpressumFixtureSource;
use Infinito\Exception\Core\NoIdentityCoreException;
use Infinito\Exception\Collection\ContainsElementException;
/**
* @author kevinfrantz
*/
class RequestedRightTest extends KernelTestCase
{
/**
* @var RequestedRightInterface
*/
private $requestedRight;
/**
* @var LayerRepositoryFactoryServiceInterface
*/
private $layerRepositoryFactoryService;
public function setUp(): void
{
self::bootKernel();
$entityManager = self::$container->get('doctrine.orm.default_entity_manager');
$this->layerRepositoryFactoryService = new LayerRepositoryFactoryService($entityManager);
$this->requestedRight = new RequestedRight();
}
public function testLayer(): void
{
$layer = LayerType::SOURCE;
$this->assertNull($this->requestedRight->setLayer($layer));
$this->assertEquals($layer, $this->requestedRight->getLayer());
}
public function testLayerException(): void
{
$this->expectException(\TypeError::class);
$this->requestedRight->getLayer();
}
public function testRequestedEntityWithoutAttributes(): void
{
$requestedSource = $this->createMock(RequestedEntity::class);
$this->requestedRight->setRequestedEntity($requestedSource);
$this->expectException(NoIdentityCoreException::class);
$this->requestedRight->getSource();
}
public function testKnownSource(): void
{
$requestedEntity = new RequestedEntity($this->layerRepositoryFactoryService);
$requestedEntity->setSlug(ImpressumFixtureSource::getSlug());
$this->requestedRight->setRequestedEntity($requestedEntity);
$this->requestedRight->setLayer(LayerType::SOURCE);
$sourceResponse1 = $this->requestedRight->getSource();
$this->assertGreaterThan(0, $sourceResponse1->getId());
$requestedEntity->setSlug('');
$this->expectException(NotFoundHttpException::class);
$this->requestedRight->getSource();
}
public function testEqualsSlug(): void
{
$slug = ImpressumFixtureSource::getSlug();
$requestedEntityEntity = new PureSource();
$requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('getSlug')->willReturn($slug);
$requestedEntity->method('hasSlug')->willReturn(true);
$requestedEntity->method('hasIdentity')->willReturn(true);
$requestedEntity->method('getEntity')->willReturn($requestedEntityEntity);
$this->assertEquals($slug, $requestedEntity->getSlug());
$this->requestedRight->setRequestedEntity($requestedEntity);
$responseSource1 = $this->requestedRight->getSource();
$responseSource2 = $this->requestedRight->getSource();
$this->assertEquals($responseSource1, $responseSource2);
}
public function testMetaEntity(): void
{
$slug = 123;
$source = $this->createMock(SourceInterface::class);
$entity = new Law();
$entity->setSource($source);
$requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('getSlug')->willReturn($slug);
$requestedEntity->method('hasSlug')->willReturn(true);
$requestedEntity->method('getEntity')->willReturn($entity);
$requestedEntity->method('hasIdentity')->willReturn(true);
$this->assertEquals($slug, $requestedEntity->getSlug());
$this->requestedRight->setRequestedEntity($requestedEntity);
$this->requestedRight->setLayer(LayerType::LAW);
$responseSource1 = $this->requestedRight->getSource();
$this->assertEquals($responseSource1, $source);
}
public function testSetActionType(): void
{
$attributType = ActionType::CREATE;
$this->requestedRight->setActionType($attributType);
$this->assertEquals($attributType, $this->requestedRight->getActionType());
$this->expectException(ContainsElementException::class);
$this->requestedRight->setActionType($attributType);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace tests\Unit\Domain\Request\User;
use PHPUnit\Framework\TestCase;
use Infinito\Domain\Request\User\RequestedUserService;
use Infinito\Domain\UserManagement\UserSourceDirectorServiceInterface;
use Infinito\Domain\Request\User\RequestedUserServiceInterface;
use Infinito\Domain\Request\Right\RequestedRightServiceInterface;
/**
* @author kevinfrantz
*/
class RequestedUserServiceTest extends TestCase
{
public function testConstructorSet(): void
{
$requestedRightService = $this->createMock(RequestedRightServiceInterface::class);
$userSourceDirectorService = $this->createMock(UserSourceDirectorServiceInterface::class);
$service = new RequestedUserService($userSourceDirectorService, $requestedRightService);
$this->assertInstanceOf(RequestedUserServiceInterface::class, $service);
}
}

View File

@@ -0,0 +1,95 @@
<?php
namespace tests\Unit\Domain\RightManagement\User;
use PHPUnit\Framework\TestCase;
use Infinito\Entity\User;
use Infinito\Domain\Request\User\RequestedUser;
use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\DBAL\Types\Meta\Right\CRUDType;
use Infinito\Entity\Source\AbstractSource;
use Infinito\Domain\UserManagement\UserSourceDirectorInterface;
use Infinito\Domain\Request\Right\RequestedRightInterface;
use Infinito\Domain\Request\Right\RequestedRight;
use Infinito\Domain\UserManagement\UserSourceDirector;
use Infinito\Repository\Source\SourceRepositoryInterface;
use Infinito\Domain\Request\Entity\RequestedEntityInterface;
use Infinito\Domain\Fixture\FixtureSource\ImpressumFixtureSource;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
use Infinito\Exception\Collection\NotPossibleSetElementException;
/**
* @author kevinfrantz
*/
class RequestedUserTest extends TestCase
{
public function testInterface(): void
{
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
$requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
$this->assertInstanceOf(RequestedRightInterface::class, $requestedUserRightFacade);
}
public function testGetters(): void
{
$reciever = $this->createMock(AbstractSource::class);
$user = $this->createMock(User::class);
$user->method('getSource')->willReturn($reciever);
$layer = LayerType::SOURCE;
$type = CRUDType::READ;
$source = $this->createMock(AbstractSource::class);
$reciever = $this->createMock(AbstractSource::class);
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
$userSourceDirector->method('getUser')->willReturn($user);
$requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedRight->method('getLayer')->willReturn($layer);
$requestedRight->method('getActionType')->willReturn($type);
$requestedRight->method('getSource')->willReturn($source);
$requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
$this->assertEquals($layer, $requestedUserRightFacade->getLayer());
$this->assertEquals($type, $requestedUserRightFacade->getActionType());
$this->assertEquals($source, $requestedUserRightFacade->getSource());
$this->assertEquals($reciever, $requestedUserRightFacade->getReciever());
}
public function testSetters(): void
{
$layer = LayerType::SOURCE;
$type = CRUDType::READ;
$requestedEntitySource = $this->createMock(RequestedEntityInterface::class);
$requestedEntitySource->method('getSlug')->willReturn(ImpressumFixtureSource::getSlug());
$requestedEntitySource->method('hasSlug')->willReturn(true);
$requestedEntitySource->method('hasIdentity')->willReturn(true);
$sourceRepository = $this->createMock(SourceRepositoryInterface::class);
$requestedRight = new RequestedRight();
$user = $this->createMock(User::class);
$userSourceDirector = new UserSourceDirector($sourceRepository, $user);
$requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
$this->assertNull($requestedUserRightFacade->setLayer($layer));
$this->assertNull($requestedUserRightFacade->setActionType($type));
$this->assertNull($requestedUserRightFacade->setRequestedEntity($requestedEntitySource));
$this->assertEquals($layer, $requestedRight->getLayer());
$this->assertEquals($type, $requestedRight->getActionType());
$this->expectException(NotCorrectInstanceCoreException::class);
$this->assertNotInstanceOf(RequestedEntityInterface::class, $requestedRight->getSource());
}
public function testSetReciever(): void
{
$reciever = $this->createMock(AbstractSource::class);
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
$requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
$this->expectException(NotPossibleSetElementException::class);
$requestedUserRightFacade->setReciever($reciever);
}
public function testGetUserDirector(): void
{
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
$requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
$this->assertEquals($userSourceDirector, $requestedUserRightFacade->getUserSourceDirector());
}
}