container = $this->prophesize(ContainerInterface::class); $em = $this->prophesize(EntityManager::class); $this->container->get('doctrine.entity_manager.orm_default')->willReturn($em); } public function testFactoryWithoutTemplate() { $factory = new HomePageFactory(); $this->container->has(TemplateRendererInterface::class)->willReturn(false); $this->assertTrue($factory instanceof HomePageFactory); $homePage = $factory($this->container->reveal()); $this->assertTrue($homePage instanceof HomePageAction); } public function testFactoryWithTemplate() { $factory = new HomePageFactory(); $this->container->has(TemplateRendererInterface::class)->willReturn(true); $this->container ->get(TemplateRendererInterface::class) ->willReturn($this->prophesize(TemplateRendererInterface::class)); $this->assertTrue($factory instanceof HomePageFactory); $homePage = $factory($this->container->reveal()); $this->assertTrue($homePage instanceof HomePageAction); } }