@@ 237-256 (lines=20) @@ | ||
234 | $this->assertEquals(299, $exception->getCode()); |
|
235 | } |
|
236 | ||
237 | public function testClientExceptions() |
|
238 | { |
|
239 | $params = [ |
|
240 | 'error' => [ |
|
241 | 'code' => 506, |
|
242 | 'message' => 'errmsg', |
|
243 | 'error_subcode' => 0, |
|
244 | 'type' => 'exception' |
|
245 | ], |
|
246 | ]; |
|
247 | $response = new FacebookResponse($this->request, json_encode($params), 401); |
|
248 | $exception = FacebookResponseException::create($response); |
|
249 | $this->assertInstanceOf('Facebook\Exceptions\FacebookClientException', $exception->getPrevious()); |
|
250 | $this->assertEquals(506, $exception->getCode()); |
|
251 | $this->assertEquals(0, $exception->getSubErrorCode()); |
|
252 | $this->assertEquals('exception', $exception->getErrorType()); |
|
253 | $this->assertEquals('errmsg', $exception->getMessage()); |
|
254 | $this->assertEquals(json_encode($params), $exception->getRawResponse()); |
|
255 | $this->assertEquals(401, $exception->getHttpStatusCode()); |
|
256 | } |
|
257 | ||
258 | public function testOtherException() |
|
259 | { |
|
@@ 258-277 (lines=20) @@ | ||
255 | $this->assertEquals(401, $exception->getHttpStatusCode()); |
|
256 | } |
|
257 | ||
258 | public function testOtherException() |
|
259 | { |
|
260 | $params = [ |
|
261 | 'error' => [ |
|
262 | 'code' => 42, |
|
263 | 'message' => 'ship love', |
|
264 | 'error_subcode' => 0, |
|
265 | 'type' => 'feature' |
|
266 | ], |
|
267 | ]; |
|
268 | $response = new FacebookResponse($this->request, json_encode($params), 200); |
|
269 | $exception = FacebookResponseException::create($response); |
|
270 | $this->assertInstanceOf('Facebook\Exceptions\FacebookOtherException', $exception->getPrevious()); |
|
271 | $this->assertEquals(42, $exception->getCode()); |
|
272 | $this->assertEquals(0, $exception->getSubErrorCode()); |
|
273 | $this->assertEquals('feature', $exception->getErrorType()); |
|
274 | $this->assertEquals('ship love', $exception->getMessage()); |
|
275 | $this->assertEquals(json_encode($params), $exception->getRawResponse()); |
|
276 | $this->assertEquals(200, $exception->getHttpStatusCode()); |
|
277 | } |
|
278 | } |
|
279 |