2019-02-03 01:01:26 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Integration\Domain\ActionManagement\Create;
|
|
|
|
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\Domain\ActionManagement\Create\CreateSourceAction;
|
2019-04-14 14:12:09 +02:00
|
|
|
use Infinito\Domain\ActionManagement\ActionDAOService;
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\Domain\ActionManagement\Create\CreateActionInterface;
|
2019-04-14 14:12:09 +02:00
|
|
|
use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
|
2019-02-03 01:01:26 +01:00
|
|
|
use Symfony\Component\HttpFoundation\RequestStack;
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\Entity\Source\PureSourceInterface;
|
|
|
|
use Infinito\Domain\RequestManagement\Action\RequestedActionService;
|
|
|
|
use Infinito\Domain\RequestManagement\Right\RequestedRightService;
|
|
|
|
use Infinito\Domain\RequestManagement\Action\RequestedActionServiceInterface;
|
2019-02-03 01:01:26 +01:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\DBAL\Types\ActionType;
|
|
|
|
use Infinito\Domain\RequestManagement\User\RequestedUserService;
|
|
|
|
use Infinito\Domain\UserManagement\UserSourceDirectorService;
|
2019-02-03 15:21:45 +01:00
|
|
|
use Symfony\Component\Security\Core\Security;
|
2019-02-13 16:26:32 +01:00
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\Domain\FormManagement\RequestedActionFormBuilderService;
|
|
|
|
use Infinito\Domain\FormManagement\FormClassNameService;
|
|
|
|
use Infinito\Domain\RequestManagement\Entity\RequestedEntityService;
|
|
|
|
use Infinito\Entity\Source\PureSource;
|
|
|
|
use Infinito\Attribut\ClassAttributInterface;
|
|
|
|
use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryService;
|
|
|
|
use Infinito\Domain\SecureManagement\SecureRequestedRightCheckerService;
|
|
|
|
use Infinito\Domain\RightManagement\RightTransformerService;
|
2019-02-03 01:01:26 +01:00
|
|
|
|
|
|
|
/**
|
2019-02-03 15:21:45 +01:00
|
|
|
* @todo Implement test and logic!!!!!
|
|
|
|
*
|
2019-02-03 01:01:26 +01:00
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
class CreateSourceActionIntegrationTest extends KernelTestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var CreateActionInterface
|
|
|
|
*/
|
|
|
|
private $createSourceAction;
|
|
|
|
|
|
|
|
/**
|
2019-04-14 14:12:09 +02:00
|
|
|
* @var ActionDAOServiceInterface
|
2019-02-03 01:01:26 +01:00
|
|
|
*/
|
|
|
|
private $actionService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var RequestedActionServiceInterface
|
|
|
|
*/
|
|
|
|
private $requestedActionService;
|
|
|
|
|
2019-02-13 16:26:32 +01:00
|
|
|
/**
|
|
|
|
* @var Request
|
|
|
|
*/
|
|
|
|
private $request;
|
|
|
|
|
2019-02-13 19:37:53 +01:00
|
|
|
/**
|
|
|
|
* @var RequestStack
|
|
|
|
*/
|
|
|
|
private $requestStack;
|
|
|
|
|
2019-02-03 15:21:45 +01:00
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
self::bootKernel();
|
2019-02-13 16:26:32 +01:00
|
|
|
$formFactory = self::$container->get('form.factory');
|
2019-02-03 15:21:45 +01:00
|
|
|
$entityManager = static::$kernel->getContainer()
|
|
|
|
->get('doctrine')
|
|
|
|
->getManager();
|
|
|
|
$security = $this->createMock(Security::class);
|
|
|
|
$userSourceDirectorService = new UserSourceDirectorService($entityManager, $security);
|
2019-02-13 16:26:32 +01:00
|
|
|
$requestedEntityService = new RequestedEntityService();
|
|
|
|
$requestedRightService = new RequestedRightService($requestedEntityService);
|
2019-02-03 15:21:45 +01:00
|
|
|
$requestedUserService = new RequestedUserService($userSourceDirectorService, $requestedRightService);
|
2019-02-13 15:29:29 +01:00
|
|
|
$this->requestedActionService = new RequestedActionService($requestedUserService);
|
2019-02-03 15:21:45 +01:00
|
|
|
$this->requestedActionService->setActionType(ActionType::CREATE);
|
2019-02-13 16:26:32 +01:00
|
|
|
$formClassNameService = new FormClassNameService();
|
|
|
|
$entityFormBuilderService = new RequestedActionFormBuilderService($formFactory, $formClassNameService, $this->requestedActionService);
|
|
|
|
$this->request = new Request();
|
2019-02-13 19:37:53 +01:00
|
|
|
$this->requestStack = new RequestStack();
|
|
|
|
$this->requestStack->push($this->request);
|
|
|
|
$layerRepositoryFactoryService = new LayerRepositoryFactoryService($entityManager);
|
|
|
|
$rightTransformerService = new RightTransformerService();
|
2019-02-16 09:19:49 +01:00
|
|
|
$secureRequestedRightChecker = new SecureRequestedRightCheckerService($rightTransformerService);
|
2019-04-14 14:12:09 +02:00
|
|
|
$this->actionService = new ActionDAOService($this->requestedActionService, $secureRequestedRightChecker, $this->requestStack, $layerRepositoryFactoryService, $entityFormBuilderService, $entityManager);
|
2019-02-03 15:21:45 +01:00
|
|
|
$this->createSourceAction = new CreateSourceAction($this->actionService);
|
|
|
|
}
|
2019-02-03 01:01:26 +01:00
|
|
|
|
2019-02-13 19:37:53 +01:00
|
|
|
public function testPreconditions(): void
|
|
|
|
{
|
|
|
|
$this->assertEquals($this->request, $this->requestStack->getCurrentRequest());
|
|
|
|
}
|
|
|
|
|
2019-02-03 15:21:45 +01:00
|
|
|
public function testCreateWithGuestUser(): void
|
|
|
|
{
|
2019-02-13 19:37:53 +01:00
|
|
|
$this->request->setMethod(Request::METHOD_POST);
|
2019-02-13 18:03:25 +01:00
|
|
|
$this->request->attributes->set(ClassAttributInterface::CLASS_ATTRIBUT_NAME, PureSource::class);
|
2019-02-03 15:21:45 +01:00
|
|
|
$this->assertInstanceOf(PureSourceInterface::class, $this->createSourceAction->execute());
|
|
|
|
}
|
2019-02-03 01:01:26 +01:00
|
|
|
|
|
|
|
// public function testCreatedWithKnownUser(): void
|
2019-02-03 15:21:45 +01:00
|
|
|
// {}
|
2019-02-03 01:01:26 +01:00
|
|
|
}
|