diff --git a/src/base_facebook.php b/src/base_facebook.php index c7ac1509..5327cd97 100644 --- a/src/base_facebook.php +++ b/src/base_facebook.php @@ -752,7 +752,9 @@ protected function _restserver($params) { // results are returned, errors are thrown if (is_array($result) && isset($result['error_code'])) { $this->throwAPIException($result); + // @codeCoverageIgnoreStart } + // @codeCoverageIgnoreEnd $method = strtolower($params['method']); if ($method === 'auth.expiresession' || @@ -809,7 +811,9 @@ protected function _graph($path, $method = 'GET', $params = array()) { // results are returned, errors are thrown if (is_array($result) && isset($result['error'])) { $this->throwAPIException($result); + // @codeCoverageIgnoreStart } + // @codeCoverageIgnoreEnd return $result; } diff --git a/tests/tests.php b/tests/tests.php index d191b2a8..e2c7e089 100644 --- a/tests/tests.php +++ b/tests/tests.php @@ -1332,6 +1332,26 @@ public function testLowercaseAuthRevokeAuthDestroysSession() { ); } + /** + * @expectedException FacebookAPIException + */ + public function testErrorCodeFromRestAPIThrowsException() { + $methods_to_stub = array( + '_oauthRequest', + ); + $constructor_args = array(array( + 'appId' => self::APP_ID, + 'secret' => self::SECRET + )); + $stub = $this->getMock( + 'TransientFacebook', $methods_to_stub, $constructor_args); + $stub + ->expects($this->once()) + ->method('_oauthRequest') + ->will($this->returnValue('{"error_code": 500}')); + $stub->api(array('method' => 'foo')); + } + protected function generateMD5HashOfRandomValue() { return md5(uniqid(mt_rand(), true)); }