mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-04-16 10:16:22 +02:00
Optimized RequestedActionTest
This commit is contained in:
parent
e5b31d7727
commit
e94f83e5f6
@ -2,30 +2,14 @@
|
|||||||
|
|
||||||
namespace Infinito\Domain\RequestManagement\Action;
|
namespace Infinito\Domain\RequestManagement\Action;
|
||||||
|
|
||||||
use Infinito\Attribut\ActionTypeAttribut;
|
|
||||||
use Infinito\DBAL\Types\ActionType;
|
|
||||||
use Infinito\DBAL\Types\Meta\Right\CRUDType;
|
|
||||||
use Infinito\Domain\RequestManagement\User\RequestedUser;
|
use Infinito\Domain\RequestManagement\User\RequestedUser;
|
||||||
use Infinito\Domain\RequestManagement\User\RequestedUserInterface;
|
use Infinito\Domain\RequestManagement\User\RequestedUserInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
* @todo Implement!
|
|
||||||
*/
|
*/
|
||||||
class RequestedAction extends RequestedUser implements RequestedActionInterface
|
class RequestedAction extends RequestedUser implements RequestedActionInterface
|
||||||
{
|
{
|
||||||
use ActionTypeAttribut{
|
|
||||||
setActionType as setActionTypeTrait;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Containes the mapping of non standard actions to a crud
|
|
||||||
*/
|
|
||||||
const ACTION_CRUD_MAP = [
|
|
||||||
ActionType::EXECUTE => CRUDType::READ,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RequestedUserInterface $requestedUser
|
* @param RequestedUserInterface $requestedUser
|
||||||
*/
|
*/
|
||||||
@ -33,38 +17,4 @@ class RequestedAction extends RequestedUser implements RequestedActionInterface
|
|||||||
{
|
{
|
||||||
parent::__construct($requestedUser->getUserSourceDirector(), $requestedUser);
|
parent::__construct($requestedUser->getUserSourceDirector(), $requestedUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @see \Infinito\Attribut\ActionTypeAttributInterface::setActionType()
|
|
||||||
*/
|
|
||||||
public function setActionType(string $actionType): void
|
|
||||||
{
|
|
||||||
$this->setActionTypeTrait($actionType);
|
|
||||||
$this->setRequestedRightCrudType($actionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $actionType
|
|
||||||
*/
|
|
||||||
private function setRequestedRightCrudType(string $actionType): void
|
|
||||||
{
|
|
||||||
$crudType = $this->getCrudType($actionType);
|
|
||||||
$this->requestedRight->setActionType($crudType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $actionType
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getCrudType(string $actionType): string
|
|
||||||
{
|
|
||||||
if (key_exists($actionType, self::ACTION_CRUD_MAP)) {
|
|
||||||
return self::ACTION_CRUD_MAP[$actionType];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $actionType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
|
|||||||
use Infinito\Domain\RequestManagement\Right\RequestedRight;
|
use Infinito\Domain\RequestManagement\Right\RequestedRight;
|
||||||
use Infinito\Domain\RequestManagement\Action\RequestedAction;
|
use Infinito\Domain\RequestManagement\Action\RequestedAction;
|
||||||
use Infinito\DBAL\Types\ActionType;
|
use Infinito\DBAL\Types\ActionType;
|
||||||
use Infinito\DBAL\Types\Meta\Right\CRUDType;
|
|
||||||
use Infinito\Repository\Source\SourceRepositoryInterface;
|
use Infinito\Repository\Source\SourceRepositoryInterface;
|
||||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||||
use Infinito\Domain\UserManagement\UserSourceDirector;
|
use Infinito\Domain\UserManagement\UserSourceDirector;
|
||||||
@ -52,12 +51,20 @@ class RequestedActionTest extends TestCase
|
|||||||
$list = ActionType::EXECUTE;
|
$list = ActionType::EXECUTE;
|
||||||
$this->action->setActionType($list);
|
$this->action->setActionType($list);
|
||||||
$this->assertEquals($list, $this->action->getActionType());
|
$this->assertEquals($list, $this->action->getActionType());
|
||||||
$this->assertEquals(CRUDType::READ, $this->requestedRight->getActionType());
|
$this->assertEquals(ActionType::EXECUTE, $this->requestedRight->getActionType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCrud(): void
|
public function testCrud(): void
|
||||||
{
|
{
|
||||||
foreach (CRUDType::getValues() as $crud) {
|
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->action->setActionType($crud);
|
||||||
$this->assertEquals($crud, $this->action->getActionType());
|
$this->assertEquals($crud, $this->action->getActionType());
|
||||||
$this->assertEquals($crud, $this->requestedRight->getActionType());
|
$this->assertEquals($crud, $this->requestedRight->getActionType());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user