diff --git a/application/symfony/src/Domain/Action/Create/CreateSourceAction.php b/application/symfony/src/Domain/Action/Create/CreateSourceAction.php index 06f2b35..75088d4 100644 --- a/application/symfony/src/Domain/Action/Create/CreateSourceAction.php +++ b/application/symfony/src/Domain/Action/Create/CreateSourceAction.php @@ -66,16 +66,16 @@ final class CreateSourceAction extends AbstractCreateAction /** * {@inheritdoc} * + * @todo Needs to be implemented and recheckt + * * @see \Infinito\Domain\Action\AbstractAction::isValid() */ protected function isValid(): bool { - //The following Exception just exists out of debuging reasons during the development process - if (!$this->form->isSubmitted()) { - throw new \Exception('The form is not submitted!'); - } + $request = $this->actionService->getRequest()->request->all(); + $this->form->submit($request); - return $this->form->isValid(); + return $this->form->isSubmitted() && $this->form->isValid(); } /** diff --git a/application/symfony/tests/Integration/Domain/Action/Create/CreateSourceActionIntegrationTest.php b/application/symfony/tests/Integration/Domain/Action/Create/CreateSourceActionIntegrationTest.php index 3f72fc1..6f5f108 100644 --- a/application/symfony/tests/Integration/Domain/Action/Create/CreateSourceActionIntegrationTest.php +++ b/application/symfony/tests/Integration/Domain/Action/Create/CreateSourceActionIntegrationTest.php @@ -66,11 +66,13 @@ class CreateSourceActionIntegrationTest extends KernelTestCase public function setUp(): void { self::bootKernel(); + $csrfToken = self::$container->get('security.csrf.token_manager')->getToken('authenticate')->getValue(); $this->formFactory = self::$container->get('form.factory'); $entityManager = static::$kernel->getContainer() ->get('doctrine') ->getManager(); - $security = $this->createMock(Security::class); + $security = self::$container->get(Security::class); + //$security = $this->createMock(Security::class); $userSourceDirectorService = new UserSourceDirectorService($entityManager, $security); $requestedEntityService = new RequestedEntityService(); $requestedRightService = new RequestedRightService($requestedEntityService); @@ -80,6 +82,7 @@ class CreateSourceActionIntegrationTest extends KernelTestCase $formClassNameService = new FormClassNameService(); $requestedActionFormBuilderService = new RequestedActionFormBuilderService($this->formFactory, $formClassNameService, $this->requestedActionService); $this->request = new Request(); + $this->request->request->set('_token', $csrfToken); $this->requestStack = new RequestStack(); $this->requestStack->push($this->request); $layerRepositoryFactoryService = new LayerRepositoryFactoryService($entityManager); @@ -97,7 +100,7 @@ class CreateSourceActionIntegrationTest extends KernelTestCase public function testCreateWithGuestUser(): void { $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()); }