mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-10 14:27:28 +01:00
Optimized RequestManagement
This commit is contained in:
parent
bd2318ab5b
commit
f3c2286a64
@ -6,7 +6,8 @@ use App\Attribut\ActionTypeAttribut;
|
|||||||
use App\DBAL\Types\ActionType;
|
use App\DBAL\Types\ActionType;
|
||||||
use App\DBAL\Types\Meta\Right\CRUDType;
|
use App\DBAL\Types\Meta\Right\CRUDType;
|
||||||
use App\Domain\RequestManagement\User\RequestedUser;
|
use App\Domain\RequestManagement\User\RequestedUser;
|
||||||
use App\Domain\RequestManagement\Right\RequestedRightInterface;
|
use App\Domain\RequestManagement\User\RequestedUserInterface;
|
||||||
|
use App\Domain\UserManagement\UserSourceDirectorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -27,11 +28,13 @@ class RequestedAction extends RequestedUser implements RequestedActionInterface
|
|||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RequestedRightInterface $requestedRight
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \App\Domain\RequestManagement\User\RequestedUser::__construct()
|
||||||
*/
|
*/
|
||||||
public function __construct(RequestedRightInterface $requestedRight)
|
public function __construct(UserSourceDirectorInterface $userSourceDirector, RequestedUserInterface $requestedUser)
|
||||||
{
|
{
|
||||||
$this->requestedRight = $requestedRight;
|
parent::__construct($userSourceDirector, $requestedUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Domain\RequestManagement\Action;
|
namespace App\Domain\RequestManagement\Action;
|
||||||
|
|
||||||
use App\Domain\RequestManagement\Right\RequestedRightServiceInterface;
|
use App\Domain\RequestManagement\User\RequestedUserServiceInterface;
|
||||||
|
use App\Domain\UserManagement\UserSourceDirectorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -10,10 +11,11 @@ use App\Domain\RequestManagement\Right\RequestedRightServiceInterface;
|
|||||||
final class RequestedActionService extends RequestedAction implements RequestedActionServiceInterface
|
final class RequestedActionService extends RequestedAction implements RequestedActionServiceInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param RequestedRightServiceInterface $requestedRightService
|
* @param UserSourceDirectorInterface $userSourceDirector
|
||||||
|
* @param RequestedUserServiceInterface $requestedUserService
|
||||||
*/
|
*/
|
||||||
public function __construct(RequestedRightServiceInterface $requestedRightService)
|
public function __construct(UserSourceDirectorInterface $userSourceDirector, RequestedUserServiceInterface $requestedUserService)
|
||||||
{
|
{
|
||||||
parent::__construct($requestedRightService);
|
parent::__construct($userSourceDirector, $requestedUserService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,6 @@ namespace App\Domain\RequestManagement\Action;
|
|||||||
*
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
interface RequestedActionServiceInterface
|
interface RequestedActionServiceInterface extends RequestedActionInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,13 @@ The request management works with different layers.
|
|||||||
|
|
||||||
### Layers
|
### Layers
|
||||||
Each layer contains out of __2 classes__ and __2 interfaces__ for it.
|
Each layer contains out of __2 classes__ and __2 interfaces__ for it.
|
||||||
One class contains the __logic__ and the other class contains the __service__. This makes the classes easier testable and mockable and follows the [SOLID Design Principles](https://en.wikipedia.org/wiki/SOLID). The layer order you can keep in mind with the acronym __RUAE__: __R__ight__U__ser__A__ction__E__ntity.
|
One class contains the __logic__ and the other class contains the __service__. This makes the classes easier testable and mockable and follows the [SOLID Design Principles](https://en.wikipedia.org/wiki/SOLID).
|
||||||
|
|
||||||
#### Right
|
|
||||||
This is the basic request layer from which the other layers inhiere.
|
|
||||||
#### User
|
|
||||||
#### Action
|
|
||||||
#### Entity
|
#### Entity
|
||||||
|
A **requested entity** contains the attributes to manage the entity which should be handled by an action
|
||||||
|
#### Right
|
||||||
|
This is the basic request layer from which the other layers inhiere. The relation from a **requested right** to a **requested entity** is 1:0,1
|
||||||
|
#### User
|
||||||
|
A **requested user** contains is a parent of **requested action**.
|
||||||
|
#### Action
|
||||||
|
A **requested action** contains inhieres from **requested user**.
|
||||||
|
@ -7,6 +7,6 @@ namespace App\Domain\RequestManagement\Right;
|
|||||||
*
|
*
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
final class RequestedRightService extends RequestedRight
|
final class RequestedRightService extends RequestedRight implements RequestedRightServiceInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
namespace App\Domain\UserManagement;
|
namespace App\Domain\UserManagement;
|
||||||
|
|
||||||
use App\Entity\UserInterface;
|
use App\Entity\UserInterface;
|
||||||
use App\DBAL\Types\SystemSlugType;
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Repository\Source\SourceRepositoryInterface;
|
use App\Repository\Source\SourceRepositoryInterface;
|
||||||
|
use App\Domain\FixtureManagement\FixtureSource\GuestUserFixtureSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -33,7 +33,7 @@ final class UserSourceDirector implements UserSourceDirectorInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->user = new User();
|
$this->user = new User();
|
||||||
$this->user->setSource($this->sourceRepository->findOneBySlug(SystemSlugType::GUEST_USER));
|
$this->user->setSource($this->sourceRepository->findOneBySlug(GuestUserFixtureSource::getSlug()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Integration\Domain\ActionManagement\Create;
|
||||||
|
|
||||||
|
use App\Domain\ActionManagement\Create\CreateSourceAction;
|
||||||
|
use App\Domain\ActionManagement\ActionService;
|
||||||
|
use App\Domain\ActionManagement\Create\CreateActionInterface;
|
||||||
|
use App\Domain\ActionManagement\ActionServiceInterface;
|
||||||
|
use App\Domain\FormManagement\EntityFormBuilderServiceInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
use App\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
|
||||||
|
use App\Domain\SecureManagement\SecureRequestedRightCheckerInterface;
|
||||||
|
use App\Entity\Source\PureSourceInterface;
|
||||||
|
use App\Domain\RequestManagement\Action\RequestedActionService;
|
||||||
|
use App\Domain\RequestManagement\Right\RequestedRightService;
|
||||||
|
use App\Domain\RequestManagement\Action\RequestedActionServiceInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
|
use App\DBAL\Types\ActionType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
class CreateSourceActionIntegrationTest extends KernelTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var CreateActionInterface
|
||||||
|
*/
|
||||||
|
private $createSourceAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ActionServiceInterface
|
||||||
|
*/
|
||||||
|
private $actionService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var RequestedActionServiceInterface
|
||||||
|
*/
|
||||||
|
private $requestedActionService;
|
||||||
|
|
||||||
|
// public function setUp(): void
|
||||||
|
// {
|
||||||
|
// self::bootKernel();
|
||||||
|
// $entityManager = static::$kernel->getContainer()->get('doctrine')->getManager();
|
||||||
|
// $requestedRightService = new RequestedRightService();
|
||||||
|
// $this->requestedActionService = new RequestedActionService($requestedRightService);
|
||||||
|
// $this->requestedActionService->setActionType(ActionType::CREATE);
|
||||||
|
// $entityFormBuilderService = $this->createMock(EntityFormBuilderServiceInterface::class);
|
||||||
|
// $requestStack = $this->createMock(RequestStack::class);
|
||||||
|
// $layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
|
||||||
|
// $secureRequestedRightChecker = $this->createMock(SecureRequestedRightCheckerInterface::class);
|
||||||
|
// $this->actionService = new ActionService($this->requestedActionService, $secureRequestedRightChecker, $requestStack, $layerRepositoryFactoryService, $entityFormBuilderService, $entityManager);
|
||||||
|
// $this->createSourceAction = new CreateSourceAction($this->actionService);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function testCreateWithGuestUser(): void
|
||||||
|
// {
|
||||||
|
// $this->requestedActionService->setReciever($reciever);
|
||||||
|
// $this->assertInstanceOf(PureSourceInterface::class, $this->createSourceAction->execute());
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function testCreatedWithKnownUser(): void
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
}
|
@ -11,6 +11,8 @@ use App\Domain\RequestManagement\Action\RequestedActionInterface;
|
|||||||
use App\Domain\RequestManagement\Action\RequestedAction;
|
use App\Domain\RequestManagement\Action\RequestedAction;
|
||||||
use App\Domain\RequestManagement\Right\RequestedRight;
|
use App\Domain\RequestManagement\Right\RequestedRight;
|
||||||
use App\Domain\LayerManagement\LayerActionMap;
|
use App\Domain\LayerManagement\LayerActionMap;
|
||||||
|
use App\Domain\RequestManagement\User\RequestedUser;
|
||||||
|
use App\Domain\UserManagement\UserSourceDirectorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -35,7 +37,9 @@ class ActionFactoryServiceTest extends TestCase
|
|||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$requestedRight = new RequestedRight();
|
$requestedRight = new RequestedRight();
|
||||||
$this->requestedAction = new RequestedAction($requestedRight);
|
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
|
||||||
|
$requestedUser = new RequestedUser($userSourceDirector, $requestedRight);
|
||||||
|
$this->requestedAction = new RequestedAction($userSourceDirector, $requestedUser);
|
||||||
$this->actionService = $this->createMock(ActionServiceInterface::class);
|
$this->actionService = $this->createMock(ActionServiceInterface::class);
|
||||||
$this->actionService->method('getRequestedAction')->willReturn($this->requestedAction);
|
$this->actionService->method('getRequestedAction')->willReturn($this->requestedAction);
|
||||||
$this->actionFactoryService = new ActionFactoryService($this->actionService);
|
$this->actionFactoryService = new ActionFactoryService($this->actionService);
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
namespace tests\Unit\Domain\RequestManagement\Action;
|
namespace tests\Unit\Domain\RequestManagement\Action;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use App\Domain\RequestManagement\Right\RequestedRightServiceInterface;
|
|
||||||
use App\Domain\RequestManagement\Action\RequestedActionService;
|
use App\Domain\RequestManagement\Action\RequestedActionService;
|
||||||
use App\Domain\RequestManagement\Action\RequestedActionServiceInterface;
|
use App\Domain\RequestManagement\Action\RequestedActionServiceInterface;
|
||||||
|
use App\Domain\RequestManagement\User\RequestedUserServiceInterface;
|
||||||
|
use App\Domain\UserManagement\UserSourceDirectorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -14,8 +15,9 @@ class RequestedActionServiceTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testConstructorSet(): void
|
public function testConstructorSet(): void
|
||||||
{
|
{
|
||||||
$requestedRightService = $this->createMock(RequestedRightServiceInterface::class);
|
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
|
||||||
$service = new RequestedActionService($requestedRightService);
|
$requestedUserService = $this->createMock(RequestedUserServiceInterface::class);
|
||||||
|
$service = new RequestedActionService($userSourceDirector, $requestedUserService);
|
||||||
$this->assertInstanceOf(RequestedActionServiceInterface::class, $service);
|
$this->assertInstanceOf(RequestedActionServiceInterface::class, $service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@ use App\DBAL\Types\ActionType;
|
|||||||
use App\DBAL\Types\Meta\Right\CRUDType;
|
use App\DBAL\Types\Meta\Right\CRUDType;
|
||||||
use App\Repository\Source\SourceRepositoryInterface;
|
use App\Repository\Source\SourceRepositoryInterface;
|
||||||
use App\DBAL\Types\Meta\Right\LayerType;
|
use App\DBAL\Types\Meta\Right\LayerType;
|
||||||
|
use App\Domain\UserManagement\UserSourceDirector;
|
||||||
|
use App\Domain\RequestManagement\User\RequestedUser;
|
||||||
|
use App\Entity\Source\Complex\UserSourceInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -34,9 +37,14 @@ class RequestedActionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
|
$userSource = $this->createMock(UserSourceInterface::class);
|
||||||
$sourceRepository = $this->createMock(SourceRepositoryInterface::class);
|
$sourceRepository = $this->createMock(SourceRepositoryInterface::class);
|
||||||
$this->requestedRight = new RequestedRight($sourceRepository);
|
$sourceRepository->method('findOneBySlug')->willReturn($userSource);
|
||||||
$this->action = new RequestedAction($this->requestedRight);
|
$user = null;
|
||||||
|
$userSourceDirector = new UserSourceDirector($sourceRepository, $user);
|
||||||
|
$requestedRight = new RequestedRight();
|
||||||
|
$this->requestedRight = new RequestedUser($userSourceDirector, $requestedRight);
|
||||||
|
$this->action = new RequestedAction($userSourceDirector, $this->requestedRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testList(): void
|
public function testList(): void
|
||||||
|
Loading…
Reference in New Issue
Block a user