예제 #1
0
 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());
 }
예제 #2
0
 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());
 }
예제 #3
0
 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;
 }