Exemplo n.º 1
0
 /**
  * testBasics method
  *
  * @return void
  */
 public function testSuccessResponse()
 {
     $response = new Att\M2X\HttpResponse($this->_raw('devices_update_location_success'));
     $expected = '{"status":"accepted"}';
     $this->assertEquals($expected, $response->raw());
     $expected = array('status' => 'accepted');
     $this->assertEquals($expected, $response->json());
     $expected = array('Server' => 'nginx', 'Date' => 'Tue, 09 Dec 2014 17:48:00 GMT', 'Content-Type' => 'application/json', 'Content-Length' => '21', 'Status' => '202 Accepted', 'X-M2X-VERSION' => 'v2.3.2-alpha', 'Vary' => 'Accept-Encoding');
     $this->assertEquals($expected, $response->headers());
     $this->assertEquals(202, $response->status());
     $this->assertTrue($response->success());
     $this->assertFalse($response->clientError());
     $this->assertFalse($response->serverError());
     $this->assertFalse($response->error());
 }
Exemplo n.º 2
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);
 }