container = $this->prophesize(ContainerInterface::class); $articleService = $this->prophesize(ArticleService::class); $this->container->get(ArticleService::class)->willReturn($articleService); } public function testFactoryWithoutTemplate() { $factory = new DeleteFactory(); $this->container->has(TemplateRendererInterface::class)->willReturn(false); $this->assertTrue($factory instanceof DeleteFactory); $page = $factory($this->container->reveal()); $this->assertTrue($page instanceof DeleteAction); } public function testFactoryWithTemplate() { $factory = new DeleteFactory(); $this->container->has(TemplateRendererInterface::class)->willReturn(true); $this->container ->get(TemplateRendererInterface::class) ->willReturn($this->prophesize(TemplateRendererInterface::class)); $this->assertTrue($factory instanceof DeleteFactory); $homePage = $factory($this->container->reveal()); $this->assertTrue($homePage instanceof DeleteAction); } }