setMethod(Request::METHOD_POST); $request->query->set(ClassAttributInterface::CLASS_ATTRIBUT_NAME, PureSource::class); $request->request->set(SlugAttributInterface::SLUG_ATTRIBUT_NAME, 'randomname'); $requestedActionService = $this->createMock(RequestedActionServiceInterface::class); $secureRequestedRightChecker = $this->createMock(SecureRequestedRightCheckerInterface::class); $entityManager = $this->createMock(EntityManagerInterface::class); $pureSourceType = $this->createMock(PureSourceTypeInterface::class); $pureSourceType->method('isValid')->willReturn(true); $formBuilderInterface = $this->createMock(FormBuilderInterface::class); $formBuilderInterface->method('getForm')->willReturn($pureSourceType); // $formBuilderInterface->method('isValid')->willReturn(true); $requestedActionFormBuilderService = $this->createMock(RequestedActionFormBuilderServiceInterface::class); $requestedActionFormBuilderService->method('createByService')->willReturn($formBuilderInterface); $requestStack = $this->createMock(RequestStack::class); $requestStack->method('getCurrentRequest')->willReturn($request); $layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class); $actionService = new ActionService($requestedActionService, $secureRequestedRightChecker, $requestStack, $layerRepositoryFactoryService, $requestedActionFormBuilderService, $entityManager); $createSourceAction = new CreateSourceAction($actionService); $result = $createSourceAction->execute(); $this->assertInstanceOf(PureSourceInterface::class, $result); } }