respFactory = $this->prophesize(ProblemDetailsResponseFactory::class); $this->logger = $this->prophesize(LoggerInterface::class); $this->middleware = new NotConfiguredMercureErrorHandler($this->respFactory->reveal(), $this->logger->reveal()); $this->handler = $this->prophesize(RequestHandlerInterface::class); } /** @test */ public function requestHandlerIsInvokedWhenNotErrorOccurs(): void { $req = ServerRequestFactory::fromGlobals(); $handle = $this->handler->handle($req)->willReturn(new Response()); $this->middleware->process($req, $this->handler->reveal()); $handle->shouldHaveBeenCalledOnce(); $this->logger->warning(Argument::cetera())->shouldNotHaveBeenCalled(); $this->respFactory->createResponseFromThrowable(Argument::cetera())->shouldNotHaveBeenCalled(); } /** @test */ public function exceptionIsParsedToResponse(): void { $req = ServerRequestFactory::fromGlobals(); $handle = $this->handler->handle($req)->willThrow(MercureException::mercureNotConfigured()); $createResp = $this->respFactory->createResponseFromThrowable(Argument::cetera())->willReturn(new Response()); $this->middleware->process($req, $this->handler->reveal()); $handle->shouldHaveBeenCalledOnce(); $createResp->shouldHaveBeenCalledOnce(); $this->logger->warning(Argument::cetera())->shouldHaveBeenCalledOnce(); } }