|
@@ 243-262 (lines=20) @@
|
| 240 |
|
$this->assertEquals(299, $exception->getCode()); |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
public function testClientExceptions() |
| 244 |
|
{ |
| 245 |
|
$params = [ |
| 246 |
|
'error' => [ |
| 247 |
|
'code' => 506, |
| 248 |
|
'message' => 'errmsg', |
| 249 |
|
'error_subcode' => 0, |
| 250 |
|
'type' => 'exception' |
| 251 |
|
], |
| 252 |
|
]; |
| 253 |
|
$response = new Response($this->request, json_encode($params), 401); |
| 254 |
|
$exception = ResponseException::create($response); |
| 255 |
|
$this->assertInstanceOf(ClientException::class, $exception->getPrevious()); |
| 256 |
|
$this->assertEquals(506, $exception->getCode()); |
| 257 |
|
$this->assertEquals(0, $exception->getSubErrorCode()); |
| 258 |
|
$this->assertEquals('exception', $exception->getErrorType()); |
| 259 |
|
$this->assertEquals('errmsg', $exception->getMessage()); |
| 260 |
|
$this->assertEquals(json_encode($params), $exception->getRawResponse()); |
| 261 |
|
$this->assertEquals(401, $exception->getHttpStatusCode()); |
| 262 |
|
} |
| 263 |
|
|
| 264 |
|
public function testOtherException() |
| 265 |
|
{ |
|
@@ 264-283 (lines=20) @@
|
| 261 |
|
$this->assertEquals(401, $exception->getHttpStatusCode()); |
| 262 |
|
} |
| 263 |
|
|
| 264 |
|
public function testOtherException() |
| 265 |
|
{ |
| 266 |
|
$params = [ |
| 267 |
|
'error' => [ |
| 268 |
|
'code' => 42, |
| 269 |
|
'message' => 'ship love', |
| 270 |
|
'error_subcode' => 0, |
| 271 |
|
'type' => 'feature' |
| 272 |
|
], |
| 273 |
|
]; |
| 274 |
|
$response = new Response($this->request, json_encode($params), 200); |
| 275 |
|
$exception = ResponseException::create($response); |
| 276 |
|
$this->assertInstanceOf(OtherException::class, $exception->getPrevious()); |
| 277 |
|
$this->assertEquals(42, $exception->getCode()); |
| 278 |
|
$this->assertEquals(0, $exception->getSubErrorCode()); |
| 279 |
|
$this->assertEquals('feature', $exception->getErrorType()); |
| 280 |
|
$this->assertEquals('ship love', $exception->getMessage()); |
| 281 |
|
$this->assertEquals(json_encode($params), $exception->getRawResponse()); |
| 282 |
|
$this->assertEquals(200, $exception->getHttpStatusCode()); |
| 283 |
|
} |
| 284 |
|
} |
| 285 |
|
|