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