@@ 117-143 (lines=27) @@ | ||
114 | $this->assertEquals(0, $exception->getSubErrorCode()); |
|
115 | } |
|
116 | ||
117 | public function testServerExceptions() |
|
118 | { |
|
119 | $params = [ |
|
120 | 'error' => [ |
|
121 | 'code' => 1, |
|
122 | 'message' => 'errmsg', |
|
123 | 'error_subcode' => 0, |
|
124 | 'type' => 'exception' |
|
125 | ], |
|
126 | ]; |
|
127 | ||
128 | $response = new Response($this->request, json_encode($params), 500); |
|
129 | $exception = ResponseException::create($response); |
|
130 | $this->assertInstanceOf(ServerException::class, $exception->getPrevious()); |
|
131 | $this->assertEquals(1, $exception->getCode()); |
|
132 | $this->assertEquals(0, $exception->getSubErrorCode()); |
|
133 | $this->assertEquals('exception', $exception->getErrorType()); |
|
134 | $this->assertEquals('errmsg', $exception->getMessage()); |
|
135 | $this->assertEquals(json_encode($params), $exception->getRawResponse()); |
|
136 | $this->assertEquals(500, $exception->getHttpStatusCode()); |
|
137 | ||
138 | $params['error']['code'] = 2; |
|
139 | $response = new Response($this->request, json_encode($params), 500); |
|
140 | $exception = ResponseException::create($response); |
|
141 | $this->assertInstanceOf(ServerException::class, $exception->getPrevious()); |
|
142 | $this->assertEquals(2, $exception->getCode()); |
|
143 | } |
|
144 | ||
145 | public function testThrottleExceptions() |
|
146 | { |
|
@@ 178-203 (lines=26) @@ | ||
175 | $this->assertEquals(341, $exception->getCode()); |
|
176 | } |
|
177 | ||
178 | public function testUserIssueExceptions() |
|
179 | { |
|
180 | $params = [ |
|
181 | 'error' => [ |
|
182 | 'code' => 230, |
|
183 | 'message' => 'errmsg', |
|
184 | 'error_subcode' => 459, |
|
185 | 'type' => 'exception' |
|
186 | ], |
|
187 | ]; |
|
188 | $response = new Response($this->request, json_encode($params), 401); |
|
189 | $exception = ResponseException::create($response); |
|
190 | $this->assertInstanceOf(AuthenticationException::class, $exception->getPrevious()); |
|
191 | $this->assertEquals(230, $exception->getCode()); |
|
192 | $this->assertEquals(459, $exception->getSubErrorCode()); |
|
193 | $this->assertEquals('exception', $exception->getErrorType()); |
|
194 | $this->assertEquals('errmsg', $exception->getMessage()); |
|
195 | $this->assertEquals(json_encode($params), $exception->getRawResponse()); |
|
196 | $this->assertEquals(401, $exception->getHttpStatusCode()); |
|
197 | ||
198 | $params['error']['error_subcode'] = 464; |
|
199 | $response = new Response($this->request, json_encode($params), 401); |
|
200 | $exception = ResponseException::create($response); |
|
201 | $this->assertInstanceOf(AuthenticationException::class, $exception->getPrevious()); |
|
202 | $this->assertEquals(464, $exception->getSubErrorCode()); |
|
203 | } |
|
204 | ||
205 | public function testAuthorizationExceptions() |
|
206 | { |