serializer = new Serializer([new ObjectNormalizer()], [new JsonEncoder()]); } public function testCreate(): void { $factory = new ErrorJsonResponseFactory($this->serializer); $error = new Error(); $error->message = 'Test error message'; $result = $factory->create($error); static::assertInstanceOf(JsonResponse::class, $result); static::assertEquals(Response::HTTP_BAD_REQUEST, $result->getStatusCode()); static::assertEquals('{"code":null,"message":"Test error message","details":null}', $result->getContent()); } }