class ExceptionHandlerFake implements ExceptionHandler, Fake mixin Handler

Traits

Properties

protected Throwable> $reported

All of the exceptions that have been reported.

protected bool $throwOnReport

If the fake should throw exceptions when they are reported.

Methods

mixed
forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

static never
throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

string
firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

array
firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

array
closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

array
closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

__construct(ExceptionHandler $handler, array $exceptions = [])

Create a new exception handler fake.

handler()

Get the underlying handler implementation.

void
assertReported(Closure|string $exception)

Assert if an exception of the given type has been reported.

void
assertReportedCount(int $count)

Assert the number of exceptions that have been reported.

void
assertNotReported(Closure|string $exception)

Assert if an exception of the given type has not been reported.

void
assertNothingReported()

Assert nothing has been reported.

void
report(Throwable $e, array $context = [], string|null $level = null)

Report or log an exception.

bool
isFakedException(Throwable $e)

Determine if the given exception is faked.

bool
shouldReport(Throwable $e)

Determine if the exception should be reported.

bool
runningWithoutExceptionHandling()

Determine if the handler is running without exception handling.

Response
render(Request $request, Throwable $e)

Render an exception into an HTTP response.

void
renderForConsole(OutputInterface $output, Throwable $e)

Render an exception to the console.

void
afterResponse(callable $callback)

Register a callback to be called after an HTTP error response is rendered.

throwOnReport()

Throw exceptions when they are reported.

throwFirstReported()

Throw the first reported exception.

array
reported()

Get the exceptions that have been reported.

setHandler(ExceptionHandler $handler)

Set the "original" handler that should be used by the fake.

bool
isReporting(Throwable $e)

Determine if a given exception is being reported.

array
buildContextForException(Throwable $e)

Create the context for an exception.

mixed
__call(string $method, array $parameters)

Handle dynamic method calls to the handler.

Details

in ForwardsCalls at line 22
protected mixed forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 52
protected mixed forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 66
static protected never throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

never

Exceptions

BadMethodCallException

in ReflectsClosures at line 26
protected string firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

Parameters

Closure $closure

Return Value

string

Exceptions

ReflectionException
RuntimeException

in ReflectsClosures at line 49
protected array firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException
RuntimeException

in ReflectsClosures at line 75
protected array closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

in ReflectsClosures at line 97
protected array closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

at line 47
__construct(ExceptionHandler $handler, array $exceptions = [])

Create a new exception handler fake.

Parameters

ExceptionHandler $handler
array $exceptions

at line 56
ExceptionHandler handler()

Get the underlying handler implementation.

Return Value

ExceptionHandler

at line 66
void assertReported(Closure|string $exception)

Assert if an exception of the given type has been reported.

Parameters

Closure|string $exception

Return Value

void

at line 95
void assertReportedCount(int $count)

Assert the number of exceptions that have been reported.

Parameters

int $count

Return Value

void

at line 113
void assertNotReported(Closure|string $exception)

Assert if an exception of the given type has not been reported.

Parameters

Closure|string $exception

Return Value

void

Exceptions

ExpectationFailedException

at line 130
void assertNothingReported()

Assert nothing has been reported.

Return Value

void

at line 149
void report(Throwable $e, array $context = [], string|null $level = null)

Report or log an exception.

Parameters

Throwable $e
array $context
string|null $level

Return Value

void

Exceptions

Throwable

at line 171
protected bool isFakedException(Throwable $e)

Determine if the given exception is faked.

Parameters

Throwable $e

Return Value

bool

at line 179
bool shouldReport(Throwable $e)

Determine if the exception should be reported.

Parameters

Throwable $e

Return Value

bool

at line 187
protected bool runningWithoutExceptionHandling()

Determine if the handler is running without exception handling.

Return Value

bool

at line 195
Response render(Request $request, Throwable $e)

Render an exception into an HTTP response.

Parameters

Request $request
Throwable $e

Return Value

Response

at line 203
void renderForConsole(OutputInterface $output, Throwable $e)

Render an exception to the console.

Parameters

OutputInterface $output
Throwable $e

Return Value

void

at line 211
void afterResponse(callable $callback)

Register a callback to be called after an HTTP error response is rendered.

Parameters

callable $callback

Return Value

void

at line 219
ExceptionHandlerFake throwOnReport()

Throw exceptions when they are reported.

Return Value

ExceptionHandlerFake

at line 231
ExceptionHandlerFake throwFirstReported()

Throw the first reported exception.

Return Value

ExceptionHandlerFake

Exceptions

Throwable

at line 245
array reported()

Get the exceptions that have been reported.

Return Value

array

at line 253
ExceptionHandlerFake setHandler(ExceptionHandler $handler)

Set the "original" handler that should be used by the fake.

Parameters

ExceptionHandler $handler

Return Value

ExceptionHandlerFake

at line 263
bool isReporting(Throwable $e)

Determine if a given exception is being reported.

Parameters

Throwable $e

Return Value

bool

at line 273
array buildContextForException(Throwable $e)

Create the context for an exception.

Parameters

Throwable $e

Return Value

array

at line 281
mixed __call(string $method, array $parameters)

Handle dynamic method calls to the handler.

Parameters

string $method
array $parameters

Return Value

mixed