container = $this->createMock(ContainerInterface::class); $this->router = $this->createMock(RouterInterface::class); } public function testReturnsJsonResponseWhenNoTemplateRendererProvided(): void { $homePage = new HomePageHandler( $this->container::class, $this->router, null ); $response = $homePage->handle( $this->createMock(ServerRequestInterface::class) ); self::assertInstanceOf(JsonResponse::class, $response); } public function testReturnsHtmlResponseWhenTemplateRendererProvided(): void { $renderer = $this->createMock(TemplateRendererInterface::class); $renderer ->expects($this->once()) ->method('render') ->with('app::home-page', $this->isType('array')) ->willReturn(''); $homePage = new HomePageHandler( $this->container::class, $this->router, $renderer ); $response = $homePage->handle( $this->createMock(ServerRequestInterface::class) ); self::assertInstanceOf(HtmlResponse::class, $response); } }