respFactory = $this->createMock(ProblemDetailsResponseFactory::class); $this->logger = $this->createMock(LoggerInterface::class); $this->middleware = new NotConfiguredMercureErrorHandler($this->respFactory, $this->logger); $this->handler = $this->createMock(RequestHandlerInterface::class); } #[Test] public function requestHandlerIsInvokedWhenNotErrorOccurs(): void { $req = ServerRequestFactory::fromGlobals(); $this->handler->expects($this->once())->method('handle')->with($req)->willReturn(new Response()); $this->respFactory->expects($this->never())->method('createResponseFromThrowable'); $this->logger->expects($this->never())->method('warning'); $this->middleware->process($req, $this->handler); } #[Test] public function exceptionIsParsedToResponse(): void { $req = ServerRequestFactory::fromGlobals(); $this->handler->expects($this->once())->method('handle')->with($req)->willThrowException( MercureException::mercureNotConfigured(), ); $this->respFactory->expects($this->once())->method('createResponseFromThrowable')->willReturn(new Response()); $this->logger->expects($this->once())->method('warning'); $this->middleware->process($req, $this->handler); } }