@@ -8,10 +8,10 @@ |
||
8 | 8 | |
9 | 9 | namespace PhpRestfulApiResponse\Tests\unit; |
10 | 10 | |
11 | +use InvalidArgumentException; |
|
11 | 12 | use PhpRestfulApiResponse\Response; |
12 | 13 | use PhpRestfulApiResponse\Tests\unit\Lib\Book; |
13 | 14 | use ReflectionClass; |
14 | -use InvalidArgumentException; |
|
15 | 15 | |
16 | 16 | class ResponseTest extends Base |
17 | 17 | { |
@@ -302,6 +302,9 @@ discard block |
||
302 | 302 | $this->run_setErrorCode($this->getMethodSetErrorCode(), "ERROR-CODE"); |
303 | 303 | } |
304 | 304 | |
305 | + /** |
|
306 | + * @param integer $code |
|
307 | + */ |
|
305 | 308 | private function run_setStatusCode(\ReflectionMethod $method, $code) |
306 | 309 | { |
307 | 310 | try { |
@@ -315,6 +318,9 @@ discard block |
||
315 | 318 | } |
316 | 319 | } |
317 | 320 | |
321 | + /** |
|
322 | + * @param string $code |
|
323 | + */ |
|
318 | 324 | private function run_setErrorCode(\ReflectionMethod $method, $code) |
319 | 325 | { |
320 | 326 | $method->invokeArgs($this->response, [$code]); |
@@ -338,6 +344,10 @@ discard block |
||
338 | 344 | } |
339 | 345 | |
340 | 346 | |
347 | + /** |
|
348 | + * @param integer $code |
|
349 | + * @param string $errorCode |
|
350 | + */ |
|
341 | 351 | private function withError(Response $response, $code, $message = null, $errorCode = null) |
342 | 352 | { |
343 | 353 | $this->assertEquals($code, $response->getStatusCode()); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
186 | - * @param $data |
|
186 | + * @param Tests\unit\Lib\Book $data |
|
187 | 187 | * @param TransformerAbstract|callable $transformer |
188 | 188 | * @param int $code |
189 | 189 | * @param null $resourceKey |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | - * @param $data |
|
210 | + * @param Tests\unit\Lib\Book[] $data |
|
211 | 211 | * @param TransformerAbstract|callable $transformer |
212 | 212 | * @param int $code |
213 | 213 | * @param null $resourceKey |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @param int $statusCode |
243 | 243 | * @param int|string $errorCode |
244 | 244 | * @param array $headers |
245 | - * @return mixed |
|
245 | + * @return Response |
|
246 | 246 | */ |
247 | 247 | public function withError($message, int $statusCode, $errorCode = null, array $headers = []) |
248 | 248 | { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param string $message |
273 | 273 | * @param int|string $errorCode |
274 | 274 | * @param array $headers |
275 | - * @return mixed |
|
275 | + * @return Response |
|
276 | 276 | */ |
277 | 277 | public function errorForbidden(string $message = '', $errorCode = null, array $headers = []) |
278 | 278 | { |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @param string $message |
286 | 286 | * @param int|string $errorCode |
287 | 287 | * @param array $headers |
288 | - * @return mixed |
|
288 | + * @return Response |
|
289 | 289 | */ |
290 | 290 | public function errorInternalError(string $message = '', $errorCode = null, array $headers = []) |
291 | 291 | { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @param string $message |
299 | 299 | * @param int|string $errorCode |
300 | 300 | * @param array $headers |
301 | - * @return mixed |
|
301 | + * @return Response |
|
302 | 302 | */ |
303 | 303 | public function errorNotFound(string $message = '', $errorCode = null, array $headers = []) |
304 | 304 | { |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @param string $message |
312 | 312 | * @param int|string $errorCode |
313 | 313 | * @param array $headers |
314 | - * @return mixed |
|
314 | + * @return Response |
|
315 | 315 | */ |
316 | 316 | public function errorUnauthorized(string $message = '', $errorCode = null, array $headers = []) |
317 | 317 | { |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @param array $message |
325 | 325 | * @param int|array $errorCode |
326 | 326 | * @param array $headers |
327 | - * @return mixed |
|
327 | + * @return Response |
|
328 | 328 | */ |
329 | 329 | public function errorWrongArgs(array $message, $errorCode = null, array $headers = []) |
330 | 330 | { |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param string $message |
338 | 338 | * @param int|string $errorCode |
339 | 339 | * @param array $headers |
340 | - * @return mixed |
|
340 | + * @return Response |
|
341 | 341 | */ |
342 | 342 | public function errorGone(string $message = '', $errorCode = null, array $headers = []) |
343 | 343 | { |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @param string $message |
351 | 351 | * @param int|string $errorCode |
352 | 352 | * @param array $headers |
353 | - * @return mixed |
|
353 | + * @return Response |
|
354 | 354 | */ |
355 | 355 | public function errorMethodNotAllowed(string $message = '', $errorCode = null, array $headers = []) |
356 | 356 | { |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @param string $message |
364 | 364 | * @param int|string $errorCode |
365 | 365 | * @param array $headers |
366 | - * @return mixed |
|
366 | + * @return Response |
|
367 | 367 | */ |
368 | 368 | public function errorUnwillingToProcess(string $message = '', $errorCode = null, array $headers = []) |
369 | 369 | { |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * @param string $message |
377 | 377 | * @param int|string $errorCode |
378 | 378 | * @param array $headers |
379 | - * @return mixed |
|
379 | + * @return Response |
|
380 | 380 | */ |
381 | 381 | public function errorUnprocessable(string $message = '', $errorCode = null, array $headers = []) |
382 | 382 | { |
@@ -8,6 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | namespace PhpRestfulApiResponse; |
10 | 10 | |
11 | +use InvalidArgumentException; |
|
11 | 12 | use League\Fractal\Manager; |
12 | 13 | use League\Fractal\Pagination\Cursor; |
13 | 14 | use League\Fractal\Resource\Collection; |
@@ -15,7 +16,6 @@ discard block |
||
15 | 16 | use League\Fractal\TransformerAbstract; |
16 | 17 | use PhpRestfulApiResponse\Contracts\PhpRestfulApiResponse; |
17 | 18 | use Zend\Diactoros\MessageTrait; |
18 | -use InvalidArgumentException; |
|
19 | 19 | use Zend\Diactoros\Response\InjectContentTypeTrait; |
20 | 20 | use Zend\Diactoros\Response\JsonResponse; |
21 | 21 |