예제 #1
0
 /**
  * testServerError method
  *
  * @return void
  */
 public function testServerError()
 {
     $response = new Att\M2X\HttpResponse($this->_raw('internal_server_error'));
     $this->assertEquals(500, $response->status());
     $this->assertFalse($response->success());
     $this->assertFalse($response->clientError());
     $this->assertTrue($response->serverError());
     $this->assertTrue($response->error());
 }
예제 #2
0
파일: M2X.php 프로젝트: attm2x/m2x-php
 /**
  * Checks the HttpResponse for errors and throws an exception, if
  * no errors are encountered, the HttpResponse is returned.
  *
  * @param HttpResponse $response
  * @return HttpResponse
  * @throws M2XException
  */
 protected function handleResponse(HttpResponse $response)
 {
     $this->lastResponse = $response;
     if ($response->success()) {
         return $response;
     }
     throw new M2XException($response);
 }
예제 #3
0
 /**
  * Create the exception from a HttpResponse object
  *
  * @param HttpResponse $response
  */
 public function __construct(HttpResponse $response)
 {
     $data = $response->json();
     $this->response = $response;
     parent::__construct($data['message'], $response->statusCode);
 }