예제 #1
0
 /**
  * @param ResponseInterface response to test
  * @param int HTTP status code to check for
  */
 private function checkResponse(ResponseInterface $response, int $expected_code)
 {
     $this->assertSame($expected_code, $response->getStatusCode(), 'Incorrect status code in response');
 }
예제 #2
0
 public function assertStatusCode($statusCode)
 {
     $this->assertEquals($statusCode, $this->response->getStatusCode());
 }
예제 #3
0
 /**
  * @param ResponseInterface $responseObj
  *
  * @return \stdClass
  *
  * @throws Exception
  */
 public function responseHandler($responseObj)
 {
     $httpResponseCode = $responseObj->getStatusCode();
     if ($httpResponseCode === 200) {
         $data = (string) $responseObj->getBody();
         $jsonResponseData = (array) json_decode($data, true);
         $result = new \stdClass();
         // return response data as json if possible, raw if not
         $result->httpResponseBody = $data && empty($jsonResponseData) ? $data : $jsonResponseData;
     } else {
         throw new \Exception(self::EXCEPTION_GENERIC_HTTP_ERROR . $this->getResponseExceptionMessage($responseObj), $httpResponseCode, $responseObj->getBody());
     }
     $result->httpResponseCode = $httpResponseCode;
     return $result;
 }