public function testResponseObjectConstructionWithCustomResponse() { $representation = new Json(); $symResponse = \Symfony\Component\HttpFoundation\Response::create(); $response = new Response($representation, $symResponse); $this->assertEquals($representation, $response->getRepresentation()); }
/** * Handle an error response exception / object * @param BadResponseException $exception * @return ErrorException $error_exception */ protected function handleErrorResponse(BadResponseException $exception) { $response = Response::create($exception->getResponse()); $errorException = new ErrorException('An error occurred on this request', 0, $exception); $errorException->setResponse($response); $contentType = $response->getHttpHeader('Content-Type'); if (!empty($contentType)) { $errorClass = $this->getErrorDocumentClass($contentType); if (!is_null($errorClass)) { $errorDocument = $errorClass::createFromString($response->getBody()); $errorException->setErrorDocument($errorDocument); } } return $errorException; }