@@ 110-136 (lines=27) @@ | ||
107 | $this->assertEquals(0, $exception->getSubErrorCode()); |
|
108 | } |
|
109 | ||
110 | public function testServerExceptions() |
|
111 | { |
|
112 | $params = [ |
|
113 | 'error' => [ |
|
114 | 'code' => 1, |
|
115 | 'message' => 'errmsg', |
|
116 | 'error_subcode' => 0, |
|
117 | 'type' => 'exception' |
|
118 | ], |
|
119 | ]; |
|
120 | ||
121 | $response = new FacebookResponse($this->request, json_encode($params), 500); |
|
122 | $exception = FacebookResponseException::create($response); |
|
123 | $this->assertInstanceOf('Facebook\Exceptions\FacebookServerException', $exception->getPrevious()); |
|
124 | $this->assertEquals(1, $exception->getCode()); |
|
125 | $this->assertEquals(0, $exception->getSubErrorCode()); |
|
126 | $this->assertEquals('exception', $exception->getErrorType()); |
|
127 | $this->assertEquals('errmsg', $exception->getMessage()); |
|
128 | $this->assertEquals(json_encode($params), $exception->getRawResponse()); |
|
129 | $this->assertEquals(500, $exception->getHttpStatusCode()); |
|
130 | ||
131 | $params['error']['code'] = 2; |
|
132 | $response = new FacebookResponse($this->request, json_encode($params), 500); |
|
133 | $exception = FacebookResponseException::create($response); |
|
134 | $this->assertInstanceOf('Facebook\Exceptions\FacebookServerException', $exception->getPrevious()); |
|
135 | $this->assertEquals(2, $exception->getCode()); |
|
136 | } |
|
137 | ||
138 | public function testThrottleExceptions() |
|
139 | { |
|
@@ 171-196 (lines=26) @@ | ||
168 | $this->assertEquals(341, $exception->getCode()); |
|
169 | } |
|
170 | ||
171 | public function testUserIssueExceptions() |
|
172 | { |
|
173 | $params = [ |
|
174 | 'error' => [ |
|
175 | 'code' => 230, |
|
176 | 'message' => 'errmsg', |
|
177 | 'error_subcode' => 459, |
|
178 | 'type' => 'exception' |
|
179 | ], |
|
180 | ]; |
|
181 | $response = new FacebookResponse($this->request, json_encode($params), 401); |
|
182 | $exception = FacebookResponseException::create($response); |
|
183 | $this->assertInstanceOf('Facebook\Exceptions\FacebookAuthenticationException', $exception->getPrevious()); |
|
184 | $this->assertEquals(230, $exception->getCode()); |
|
185 | $this->assertEquals(459, $exception->getSubErrorCode()); |
|
186 | $this->assertEquals('exception', $exception->getErrorType()); |
|
187 | $this->assertEquals('errmsg', $exception->getMessage()); |
|
188 | $this->assertEquals(json_encode($params), $exception->getRawResponse()); |
|
189 | $this->assertEquals(401, $exception->getHttpStatusCode()); |
|
190 | ||
191 | $params['error']['error_subcode'] = 464; |
|
192 | $response = new FacebookResponse($this->request, json_encode($params), 401); |
|
193 | $exception = FacebookResponseException::create($response); |
|
194 | $this->assertInstanceOf('Facebook\Exceptions\FacebookAuthenticationException', $exception->getPrevious()); |
|
195 | $this->assertEquals(464, $exception->getSubErrorCode()); |
|
196 | } |
|
197 | ||
198 | public function testAuthorizationExceptions() |
|
199 | { |