2019-01-20 12:54:56 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace tests\Unit\Domain\RequestManagement\Action;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\Domain\RequestManagement\Right\RequestedRightInterface;
|
|
|
|
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
|
|
|
|
use Infinito\Domain\RequestManagement\Right\RequestedRight;
|
|
|
|
use Infinito\Domain\RequestManagement\Action\RequestedAction;
|
|
|
|
use Infinito\DBAL\Types\ActionType;
|
|
|
|
use Infinito\DBAL\Types\Meta\Right\CRUDType;
|
|
|
|
use Infinito\Repository\Source\SourceRepositoryInterface;
|
|
|
|
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
|
|
|
use Infinito\Domain\UserManagement\UserSourceDirector;
|
|
|
|
use Infinito\Domain\RequestManagement\User\RequestedUser;
|
|
|
|
use Infinito\Entity\Source\Complex\UserSourceInterface;
|
2019-01-20 12:54:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
class RequestedActionTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var RequestedRightInterface
|
|
|
|
*/
|
|
|
|
private $requestedRight;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var RequestedActionInterface
|
|
|
|
*/
|
|
|
|
private $action;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*
|
|
|
|
* @see \PHPUnit\Framework\TestCase::setUp()
|
|
|
|
*/
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
2019-02-03 01:01:26 +01:00
|
|
|
$userSource = $this->createMock(UserSourceInterface::class);
|
2019-01-20 12:54:56 +01:00
|
|
|
$sourceRepository = $this->createMock(SourceRepositoryInterface::class);
|
2019-02-03 01:01:26 +01:00
|
|
|
$sourceRepository->method('findOneBySlug')->willReturn($userSource);
|
|
|
|
$user = null;
|
|
|
|
$userSourceDirector = new UserSourceDirector($sourceRepository, $user);
|
|
|
|
$requestedRight = new RequestedRight();
|
|
|
|
$this->requestedRight = new RequestedUser($userSourceDirector, $requestedRight);
|
2019-02-13 15:29:29 +01:00
|
|
|
$this->action = new RequestedAction($this->requestedRight);
|
2019-01-20 12:54:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testList(): void
|
|
|
|
{
|
2019-02-18 21:09:57 +01:00
|
|
|
$list = ActionType::EXECUTE;
|
2019-01-20 12:54:56 +01:00
|
|
|
$this->action->setActionType($list);
|
|
|
|
$this->assertEquals($list, $this->action->getActionType());
|
2019-02-21 18:46:57 +01:00
|
|
|
$this->assertEquals(CRUDType::READ, $this->requestedRight->getActionType());
|
2019-01-20 12:54:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testCrud(): void
|
|
|
|
{
|
2019-02-25 13:32:37 +01:00
|
|
|
foreach (CRUDType::getValues() as $crud) {
|
2019-01-20 12:54:56 +01:00
|
|
|
$this->action->setActionType($crud);
|
|
|
|
$this->assertEquals($crud, $this->action->getActionType());
|
2019-02-21 18:46:57 +01:00
|
|
|
$this->assertEquals($crud, $this->requestedRight->getActionType());
|
2019-01-20 12:54:56 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-27 18:38:21 +01:00
|
|
|
|
|
|
|
public function testLayer(): void
|
|
|
|
{
|
2019-02-25 13:32:37 +01:00
|
|
|
foreach (LayerType::getValues() as $LayerType) {
|
2019-01-27 18:38:21 +01:00
|
|
|
$this->action->setLayer($LayerType);
|
|
|
|
$this->assertEquals($LayerType, $this->action->getLayer());
|
|
|
|
$this->assertEquals($LayerType, $this->requestedRight->getLayer());
|
|
|
|
}
|
|
|
|
}
|
2019-01-20 12:54:56 +01:00
|
|
|
}
|