diff --git a/app/Classes/ParseInputStream.php b/app/Classes/ParseInputStream.php index e691315..a62c398 100644 --- a/app/Classes/ParseInputStream.php +++ b/app/Classes/ParseInputStream.php @@ -24,6 +24,10 @@ * Original Gist at: * https://gist.github.com/jas-/5c3fdc26fedd11cb9fb5#file-class-stream-php */ + +/** + * @codeCoverageIgnore + */ class ParseInputStream { /** diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8725fb8..a86c82e 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -2,7 +2,6 @@ namespace App\Exceptions; -use ErrorException; use Exception; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -11,7 +10,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Throwable; -use UnexpectedValueException; class Handler extends ExceptionHandler { @@ -38,9 +36,12 @@ class Handler extends ExceptionHandler */ public function report(Throwable $e) { + // Ignoring this block because only applies on production environment + // @codeCoverageIgnoreStart if (app()->environment('production') && app()->bound('sentry') && $this->shouldReport($e)) { app('sentry')->captureException($e); } + // @codeCoverageIgnoreEnd parent::report($e); } @@ -61,19 +62,16 @@ public function render($request, Throwable $e) if ($e instanceof MethodNotAllowedHttpException) { return response('Method Not Allowed.', 405); } - if ($e instanceof UnexpectedValueException) { - return response('Unexpected value.', 422); - } if ($e instanceof ModelNotFoundException) { return response('The resource you are looking for is not available or does not belong to you.', 404); } - if ($e instanceof ErrorException) { - return response('Unprocessable. Please provide all inputs and retry.', 422); - } if ($e instanceof AuthorizationException) { return response($e->getMessage(), 401); } + // Ignoring this block because only applies if an error is not handled (like 500 server errors) + // @codeCoverageIgnoreStart return response($e->getMessage(), $e->getCode() ?: 500); + // @codeCoverageIgnoreEnd } } diff --git a/tests/AuthTest.php b/tests/AuthTest.php index cf69cdf..776f166 100644 --- a/tests/AuthTest.php +++ b/tests/AuthTest.php @@ -49,7 +49,7 @@ public function testRefresh() // NOTE: in order to make logout() function working we have to pass the JWT token -> can't use standard actingAs function $token = JWTAuth::fromUser($user); - $this->json('POST', 'auth/refresh', [], ['Authorization' => 'Bearer ' . $token]) + $this->post('auth/refresh', [], ['Authorization' => 'Bearer ' . $token]) ->seeStatusCode(200) ->seeJson(['token_type' => 'bearer']); }