get('form.factory'); //$entityManager = self::$container->get('doctrine.orm.default_entity_manager'); $entityManager = $this->createMock(EntityManagerInterface::class); $userSourceDirectorService = $this->createMock(UserSourceDirectorServiceInterface::class); $formClassNameService = new FormClassNameService(); $layerRepositoryFactoryService = new LayerRepositoryFactoryService($entityManager); $this->requestedEntity = new RequestedEntityService($layerRepositoryFactoryService); $requestedRightService = new RequestedRightService(); $requestedRightService->setRequestedEntity($this->requestedEntity); $requestedUserService = new RequestedUserService($userSourceDirectorService, $requestedRightService); $this->requestedActionService = new RequestedActionService($requestedUserService); $this->requestedActionService->setActionType(ActionType::CREATE); $this->requestedActionFormBuilderService = new RequestedActionFormBuilderService($formFactory, $formClassNameService, $this->requestedActionService); } public function testCreate(): void { $class = PureSource::class; $this->requestedEntity->setClass($class); $result = $this->requestedActionFormBuilderService->create($this->requestedActionService); $this->assertInstanceOf(FormBuilderInterface::class, $result); $this->assertInstanceOf(Form::class, $result->getForm()); $this->assertTrue(method_exists($result->getForm(), 'isValid')); //Tests if the origine builder and the service function return the same value by the requestedActionService $this->assertEquals($this->requestedActionFormBuilderService->create($this->requestedActionService), $this->requestedActionFormBuilderService->createByService()); } }