コード例 #1
0
 public function testGet_error_message()
 {
     $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']);
     $result = $this->object->get_error_message($request, API_V1_result::ERROR_BAD_REQUEST, 'detaillage');
     $this->assertTrue(is_array(json_decode($result->format(), true)));
     $this->assertEquals(400, $result->get_http_code());
     $this->assertEquals('application/json', $result->get_content_type());
     $result = $this->object->get_error_message($request, API_V1_result::ERROR_FORBIDDEN, 'detaillage');
     $this->assertTrue(is_array(json_decode($result->format(), true)));
     $this->assertEquals(403, $result->get_http_code());
     $this->assertEquals('application/json', $result->get_content_type());
     $result = $this->object->get_error_message($request, API_V1_result::ERROR_INTERNALSERVERERROR, 'detaillage');
     $this->assertTrue(is_array(json_decode($result->format(), true)));
     $this->assertEquals(500, $result->get_http_code());
     $this->assertEquals('application/json', $result->get_content_type());
     $result = $this->object->get_error_message($request, API_V1_result::ERROR_METHODNOTALLOWED, 'detaillage');
     $this->assertTrue(is_array(json_decode($result->format(), true)));
     $this->assertEquals(405, $result->get_http_code());
     $this->assertEquals('application/json', $result->get_content_type());
     $result = $this->object->get_error_message($request, API_V1_result::ERROR_NOTFOUND, 'detaillage');
     $this->assertTrue(is_array(json_decode($result->format(), true)));
     $this->assertEquals(404, $result->get_http_code());
     $this->assertEquals('application/json', $result->get_content_type());
     $result = $this->object->get_error_message($request, API_V1_result::ERROR_UNAUTHORIZED, 'detaillage');
     $this->assertTrue(is_array(json_decode($result->format(), true)));
     $this->assertEquals(401, $result->get_http_code());
     $this->assertEquals('application/json', $result->get_content_type());
 }