mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 17:29:04 +00:00 
			
		
		
		
	Optimized test and CreateSourceAction
This commit is contained in:
		| @@ -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(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -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()); | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user