From 8b5fb33ac4e181447808f05a92c5a7923b75b811 Mon Sep 17 00:00:00 2001 From: Maksim Lanin Date: Mon, 25 May 2020 10:21:41 +0300 Subject: [PATCH] Fix tests for 7.0 --- src/ApiException.php | 3 +-- tests/ExceptionsOutputTest.php | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ApiException.php b/src/ApiException.php index ac5d2a3..3dfee3c 100644 --- a/src/ApiException.php +++ b/src/ApiException.php @@ -7,7 +7,6 @@ use Illuminate\Support\Str; use Lanin\Laravel\ApiExceptions\Contracts\ShowsPrevious; use Lanin\Laravel\ApiExceptions\Contracts\ShowsTrace; -use Symfony\Component\Debug\Exception\FlattenException; abstract class ApiException extends IdException implements Jsonable, \JsonSerializable, Arrayable { @@ -83,7 +82,7 @@ public function toArray() } if (env('APP_DEBUG') && $this instanceof ShowsTrace) { - $return['trace'] = FlattenException::create($e)->getTrace(); + $return['trace'] = \Symfony\Component\ErrorHandler\Exception\FlattenException::create($e)->getTrace(); } return $return; diff --git a/tests/ExceptionsOutputTest.php b/tests/ExceptionsOutputTest.php index 620396a..500988d 100644 --- a/tests/ExceptionsOutputTest.php +++ b/tests/ExceptionsOutputTest.php @@ -2,7 +2,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException; use Lanin\Laravel\ApiExceptions\Support\Request; -use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\ErrorHandler\Error\FatalError; class ExceptionsOutputTest extends TestCase { @@ -58,7 +58,7 @@ public function test_validation_error() public function test_internal_error_error() { $this->app['router']->get('foo', function () { - throw new FatalErrorException('Fatal error.', 0, 1, __FILE__, __LINE__); + throw new \Exception('Fatal error'); }); $this->json('GET', '/foo') @@ -76,14 +76,14 @@ public function test_internal_error_in_debug_mode() putenv('APP_DEBUG=true'); $this->app['router']->get('foo', function () { - throw new FatalErrorException('Fatal error.', 0, 1, __FILE__, __LINE__); + throw new \Exception('Fatal error'); }); $this->json('GET', '/foo') ->assertStatus(500) ->assertJsonFragment([ - 'id' => 'fatal_error_exception', - 'message' => 'Fatal error.' + 'id' => 'exception', + 'message' => 'Fatal error' ]) ->assertJsonStructure([ 'trace', @@ -154,4 +154,4 @@ public function rules() 'name' => 'required' ]; } -} \ No newline at end of file +}