public function testSetRequest() { $httpResponse = new GuzzleResponse(200); $response = new Response(); $response->setResponse($httpResponse); $request = $this->getMockBuilder('\\Kintone\\Request')->disableOriginalConstructor()->getMock(); $request->method('get')->willReturn($httpResponse); $obj = new Object($request); $requestedResponse = $obj->get(); $this->assertEquals($response->getStatusCode(), $requestedResponse->getStatusCode()); }
public function testGetJsonValue() { $json = '{ "message":"不正なJSON文字列です。", "id":"1505999166-897850006", "code":"CB_IJ01" }'; $response = new Response(); $response->setResponse(new GuzzleResponse(200, [], GuzzleStream::factory($json))); $this->assertEquals("CB_IJ01", $response->getValue("code")); $this->assertEquals("CB_IJ01", $response->getCode()); }
public function post(array $options = []) { $response = new Response(); try { $http_response = $this->getRequest()->post($this->getCommand(), $options); $response->setResponse($http_response); } catch (\GuzzleHttp\Exception\RequestException $e) { if ($e->hasResponse()) { $response->setResponse($e->getResponse()); } } $response->setObject($this); return $response; }