/** * @expectedException \RuntimeException */ public function testJson() { $this->object->setBody('{"key":"value"}'); $this->assertEquals(["key" => "value"], $this->object->json()); $this->object->setBody('{invalidJson}'); $this->object->json(); }
/** * Build a new reponse object from handle execution result * @param string $content Response content * @param ExecutionInfos $infos Execution details * @param Request\AbstractRequest $request * @return Response */ public static function build($content, ExecutionInfos $infos, Request\AbstractRequest $request) { $response = new Response($request); $response->setStatus($infos->status); $response->setTransactionTime($infos->transactionTime); $response->setExecutionInfos($infos); //Populate request headers with all really sent headers if (!empty($infos->headers)) { self::parseHeaders($infos->headers, $request); } //Headers are returned with content, so we extract it $content = self::parseHeaders($content, $response); $response->setBody($content); return $response; }