Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
27pchrisl committed Mar 21, 2024
1 parent 18bbfc1 commit aa9c37b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Exception/Protocol/ProtocolException.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,9 @@ public function toResponse($request = null): Response

return $response;
}

public function getInnerException(): ?Throwable
{
return $this->originalException;
}
}
15 changes: 13 additions & 2 deletions tests/Protocol/ErrorReportingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use Flat3\Lodata\Tests\TestCase;
use Flat3\Lodata\Type;
use Generator;
use Illuminate\Foundation\Exceptions\Handler;
use Illuminate\Support\Facades\Log;
use Illuminate\Testing\TestResponse;

class ErrorReportingTest extends TestCase
Expand Down Expand Up @@ -90,11 +92,20 @@ public function test_get_original_exception()
->path('/divzero()')
);

$innerException = $testResponse->exception->getOriginalException();

if (PHP_VERSION_ID > 80000) {
$this->assertInstanceOf(DivisionByZeroError::class, $testResponse->exception->getOriginalException());
$this->assertInstanceOf(DivisionByZeroError::class, $innerException);
} else {
$this->assertInstanceOf(ErrorException::class, $testResponse->exception->getOriginalException());
$this->assertInstanceOf(ErrorException::class, $innerException);
}

$spy = Log::spy();
$handler = app(Handler::class);
$handler->report($testResponse->exception);
$spy->shouldHaveReceived('error', function ($message, $context) use ($innerException) {
return $message === $innerException->getMessage() && $context['exception'] instanceof DivisionByZeroError;
});
}

public function test_stream_error()
Expand Down

0 comments on commit aa9c37b

Please sign in to comment.