mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2024-12-04 23:17:19 +01:00
Optimized test and CreateSourceAction
This commit is contained in:
parent
893467acca
commit
66ea3e83fd
@ -66,16 +66,16 @@ final class CreateSourceAction extends AbstractCreateAction
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
|
* @todo Needs to be implemented and recheckt
|
||||||
|
*
|
||||||
* @see \Infinito\Domain\Action\AbstractAction::isValid()
|
* @see \Infinito\Domain\Action\AbstractAction::isValid()
|
||||||
*/
|
*/
|
||||||
protected function isValid(): bool
|
protected function isValid(): bool
|
||||||
{
|
{
|
||||||
//The following Exception just exists out of debuging reasons during the development process
|
$request = $this->actionService->getRequest()->request->all();
|
||||||
if (!$this->form->isSubmitted()) {
|
$this->form->submit($request);
|
||||||
throw new \Exception('The form is not submitted!');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->form->isValid();
|
return $this->form->isSubmitted() && $this->form->isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,11 +66,13 @@ class CreateSourceActionIntegrationTest extends KernelTestCase
|
|||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
self::bootKernel();
|
self::bootKernel();
|
||||||
|
$csrfToken = self::$container->get('security.csrf.token_manager')->getToken('authenticate')->getValue();
|
||||||
$this->formFactory = self::$container->get('form.factory');
|
$this->formFactory = self::$container->get('form.factory');
|
||||||
$entityManager = static::$kernel->getContainer()
|
$entityManager = static::$kernel->getContainer()
|
||||||
->get('doctrine')
|
->get('doctrine')
|
||||||
->getManager();
|
->getManager();
|
||||||
$security = $this->createMock(Security::class);
|
$security = self::$container->get(Security::class);
|
||||||
|
//$security = $this->createMock(Security::class);
|
||||||
$userSourceDirectorService = new UserSourceDirectorService($entityManager, $security);
|
$userSourceDirectorService = new UserSourceDirectorService($entityManager, $security);
|
||||||
$requestedEntityService = new RequestedEntityService();
|
$requestedEntityService = new RequestedEntityService();
|
||||||
$requestedRightService = new RequestedRightService($requestedEntityService);
|
$requestedRightService = new RequestedRightService($requestedEntityService);
|
||||||
@ -80,6 +82,7 @@ class CreateSourceActionIntegrationTest extends KernelTestCase
|
|||||||
$formClassNameService = new FormClassNameService();
|
$formClassNameService = new FormClassNameService();
|
||||||
$requestedActionFormBuilderService = new RequestedActionFormBuilderService($this->formFactory, $formClassNameService, $this->requestedActionService);
|
$requestedActionFormBuilderService = new RequestedActionFormBuilderService($this->formFactory, $formClassNameService, $this->requestedActionService);
|
||||||
$this->request = new Request();
|
$this->request = new Request();
|
||||||
|
$this->request->request->set('_token', $csrfToken);
|
||||||
$this->requestStack = new RequestStack();
|
$this->requestStack = new RequestStack();
|
||||||
$this->requestStack->push($this->request);
|
$this->requestStack->push($this->request);
|
||||||
$layerRepositoryFactoryService = new LayerRepositoryFactoryService($entityManager);
|
$layerRepositoryFactoryService = new LayerRepositoryFactoryService($entityManager);
|
||||||
@ -97,7 +100,7 @@ class CreateSourceActionIntegrationTest extends KernelTestCase
|
|||||||
public function testCreateWithGuestUser(): void
|
public function testCreateWithGuestUser(): void
|
||||||
{
|
{
|
||||||
$this->request->setMethod(Request::METHOD_POST);
|
$this->request->setMethod(Request::METHOD_POST);
|
||||||
$this->request->attributes->set(ClassAttributInterface::CLASS_ATTRIBUT_NAME, PureSource::class);
|
$this->request->request->set(ClassAttributInterface::CLASS_ATTRIBUT_NAME, PureSource::class);
|
||||||
$this->assertInstanceOf(PureSourceInterface::class, $this->createSourceAction->execute());
|
$this->assertInstanceOf(PureSourceInterface::class, $this->createSourceAction->execute());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user