Created
April 24, 2023 16:33
-
-
Save inxilpro/b9e7d8ecbcb3111cf2f349eabcad26eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Contracts\Debug\ExceptionHandler; | |
trait InteractsWithExceptionReports | |
{ | |
protected function expectsExceptionReport( | |
string|Closure $expected, | |
?string $message = null | |
) { | |
if (is_string($expected)) { | |
$class = $expected; | |
$expected = static fn($exception) => $exception instanceof $class | |
&& (null === $message || $exception->getMessage() === $message); | |
} | |
return $this->partialMock(ExceptionHandler::class) | |
->shouldReceive('report') | |
->withArgs($expected); | |
} | |
protected function doesntExpectExceptionReports() | |
{ | |
return $this->partialMock(ExceptionHandler::class) | |
->shouldNotReceive('report'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment