Skip to content

Commit

Permalink
Fix tests for 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mlanin committed May 25, 2020
1 parent 1eec592 commit 8b5fb33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions tests/ExceptionsOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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')
Expand All @@ -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',
Expand Down Expand Up @@ -154,4 +154,4 @@ public function rules()
'name' => 'required'
];
}
}
}

0 comments on commit 8b5fb33

Please sign in to comment.