public function testCreateWithErrorJSONError() { $code = 200; $rawResult = 'callback({"code":400,"msg":"11","request_id":"22"})'; $response = new ResponseJsonObject(); $response->create($code, $rawResult); $this->assertFalse($response->isOk()); $this->assertEquals($rawResult, $response->getRawResult()); $error = $response->getError(); $this->assertEquals('PARSE_ERROR_RESPONSE_JSON', $error); }
public function testCreateWithHttpErrorCode() { $code = 403; $rawResult = '{"time_get_response":{"time":"2015-09-16 15:53:37","request_id":"alibabaalibabaalibaba"}}'; $response = new ResponseJsonObject(); $response->create($code, $rawResult); $this->assertFalse($response->isOk()); $this->assertEquals($rawResult, $response->getRawResult()); $error = $response->getError(); $this->assertEquals('HTTP_CODE_ERROR', $error); }