/** Returns a reference to the response content. * * @return static */ public function invoke() { if (!$this->hasEncapsulatedObject()) { $this->setEncapsulatedObject(JsonApi_Response::factory(new JsonApi_Http_Response(Zend_Uri::factory($this->getBrowser()->getRequest()->getUri()), $this->getBrowser()->getResponse()->getStatusCode(), $this->getBrowser()->getResponse()->getContent()))); } return $this; }
public function testUnparseableResponse() { $response = JsonApi_Response::factory(new JsonApi_Http_Response($this->_uri, self::HTTP_STATUS_OK, 'This is not JSON. This is only a tribute.')); $this->assertInstanceOf('JsonApi_Response_Error', $response, 'Expected unparseable content to be encapsulated in an error object.'); /* Since we're here, let's also make sure we can convert the error response * into an exception. */ try { $response->throwException(); $this->fail('Expected JsonApi_Response_RethrownException to be thrown.'); } catch (JsonApi_Response_RethrownException $e) { } }
/** Creates a JsonApi_Response object from this HTTP response. * * @return JsonApi_Response */ public function makeJsonApiResponse() { return JsonApi_Response::factory($this); }
/** Generates a response object. * * @param int $httpStatus * @param array $content * * @return JsonApi_Response */ protected function _genResponse($httpStatus, array $content) { return JsonApi_Response::factory(new JsonApi_Http_Response($this->_uri, $httpStatus, json_encode($content))); }