Esempio n. 1
0
 private function checkResponseField(API_V1_result $result, $field, $type)
 {
     $response = json_decode($result->format(), true);
     $this->assertArrayHasKey($field, $response['response']);
     $this->assertInternalType($type, $response['response'][$field]);
 }
Esempio n. 2
0
 private function assertErrorMessage(API_V1_result $api_result, $code, $type, $message, $detail)
 {
     $response = json_decode($api_result->format());
     $this->checkResponseFieldMeta($response, 'http_code', $code, PHPUnit_Framework_Constraint_IsType::TYPE_INT);
     if (is_null($type)) {
         $this->assertObjectHasAttribute('error_type', $response->meta);
         $this->assertNull($response->meta->error_type);
     } else {
         $this->checkResponseFieldMeta($response, 'error_type', $type, PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
     }
     if (is_null($message)) {
         $this->assertObjectHasAttribute('error_message', $response->meta);
         $this->assertNull($response->meta->error_message);
     } else {
         $this->checkResponseFieldMeta($response, 'error_message', $message, PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
     }
     if (is_null($detail)) {
         $this->assertObjectHasAttribute('error_details', $response->meta);
         $this->assertNull($response->meta->error_details);
     } else {
         $this->checkResponseFieldMeta($response, 'error_details', $detail, PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
     }
 }