app = $this->makeEmpty(App::class, [ 'getResponseFactory' => $this->makeEmpty(ResponseFactoryInterface::class, [ 'createResponse' => $this->makeEmpty(ResponseInterface::class, [ 'getBody' => $this->makeEmpty(StreamInterface::class, [ 'write' => function (mixed $data) { $this->assertIsString($data); $this->assertJson($data); }, ]), ]), ]), ]); $this->request = $this->makeEmpty(ServerRequestInterface::class); } /** * @throws Exception */ public function testUseWithLogger(): void { $this->exception = $this->make(Exception::class, [ 'message' => '', 'code' => 400, 'file' => '/path(to/file', ]); $this->logger = $this->makeEmpty(LoggerInterface::class, [ 'error' => Expected::once(), ]); $middleWare = new ErrorHandler($this->app); $middleWare($this->request, $this->exception, true, true, true, $this->logger); } /** * @throws Exception */ public function testUseWithHttpException(): void { $this->exception = $this->make(HttpException::class, [ 'message' => '', 'code' => 400, 'file' => '/path(to/file', 'getTitle' => Expected::once('The Title'), ]); $this->logger = $this->makeEmpty(LoggerInterface::class, []); $middleWare = new ErrorHandler($this->app); $middleWare($this->request, $this->exception, true, true, true, $this->logger); } /** * @throws Exception */ public function testUseWithGeneralException(): void { $this->exception = $this->make(Exception::class, [ 'message' => '', 'code' => 400, 'file' => '/path(to/file', ]); $this->logger = $this->makeEmpty(LoggerInterface::class, []); $middleWare = new ErrorHandler($this->app); $middleWare($this->request, $this->exception, true, true, true, $this->logger); } }