createMock(FormBuilderInterface::class); $formBuilder = $this->createMock(FormBuilderInterface::class); $formBuilder->method('create')->willReturn($expectedResult); $formClassNameService = $this->createMock(FormClassNameServiceInterface::class); $formClassNameService->method('getName')->willReturn('dummyNamespace'); $entityFormBuilderService = new EntityFormBuilderService($formBuilder, $formClassNameService); $entity = $this->createMock(EntityInterface::class); $result = $entityFormBuilderService->create($entity); $this->assertEquals($expectedResult, $result); } }