EventFake
class EventFake implements Fake, Dispatcher
Traits
Properties
| Dispatcher | $dispatcher | The original event dispatcher. |
|
| protected array | $eventsToFake | The event types that should be intercepted instead of dispatched. |
|
| protected array | $eventsToDispatch | The event types that should be dispatched instead of intercepted. |
|
| protected array | $events | All of the events that have been intercepted keyed by type. |
Methods
Forward a method call to the given object.
Forward a method call to the given object, returning $this if the forwarded call returned itself.
Throw a bad method call exception for the given method.
Resolve a truth-test callback or an array of expected properties.
Get the class name of the first parameter of the given Closure.
Get the class names of the first parameter of the given Closure, including union types.
Get the class names / types of the parameters of the given Closure.
Get the class names / types of the return type of the given Closure.
Create a new event fake instance.
Specify the events that should be dispatched instead of faked.
Assert if an event has a listener attached to it.
Assert if an event was dispatched based on a truth-test callback.
Assert if an event was dispatched exactly once.
Assert if an event was dispatched a number of times.
Determine if an event was dispatched based on a truth-test callback.
Assert that no events were dispatched.
Get all of the events matching a truth-test callback.
Determine if the given event has been dispatched.
Register an event listener with the dispatcher.
Register a passive event observer with the dispatcher.
Determine if a given event has listeners.
Register an event and payload to be dispatched later.
Register an event subscriber with the dispatcher.
Flush a set of pushed events.
Fire an event and call the listeners.
Determine if an event should be faked or actually dispatched.
Push the event onto the fake events array immediately or after the next database transaction.
Determine whether an event should be dispatched or not.
Remove a set of listeners from the dispatcher.
Forget all events queued via push() in the current coroutine.
Dispatch an event and call the listeners.
Get the events that have been dispatched.
Handle dynamic method calls to the dispatcher.
Details
in
ForwardsCalls at line 22
protected mixed
forwardCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object.
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.
in
ForwardsCalls at line 66
static protected never
throwBadMethodCallException(string $method)
Throw a bad method call exception for the given method.
in
MatchesProperties at line 19
protected callable|null
resolveTruthTest(callable|array|null $callback)
Resolve a truth-test callback or an array of expected properties.
in
ReflectsClosures at line 26
protected string
firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure.
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.
in
ReflectsClosures at line 75
protected array
closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure.
in
ReflectsClosures at line 97
protected array
closureReturnTypes(Closure $closure)
Get the class names / types of the return type of the given Closure.
at line 49
__construct(Dispatcher $dispatcher, array|string $eventsToFake = [])
Create a new event fake instance.
at line 61
EventFake
except(array|string $eventsToDispatch)
Specify the events that should be dispatched instead of faked.
at line 74
void
assertListening(string $expectedEvent, array|string $expectedListener)
Assert if an event has a listener attached to it.
at line 122
void
assertDispatched(Closure|string $event, callable|array|int|null $callback = null)
Assert if an event was dispatched based on a truth-test callback.
at line 142
void
assertDispatchedOnce(string $event)
Assert if an event was dispatched exactly once.
at line 150
void
assertDispatchedTimes(string $event, int $times = 1)
Assert if an event was dispatched a number of times.
at line 170
void
assertNotDispatched(Closure|string $event, callable|array|null $callback = null)
Determine if an event was dispatched based on a truth-test callback.
at line 186
void
assertNothingDispatched()
Assert that no events were dispatched.
at line 211
Collection
dispatched(string $event, callable|array|null $callback = null)
Get all of the events matching a truth-test callback.
at line 229
bool
hasDispatched(string $event)
Determine if the given event has been dispatched.
at line 239
void
listen(array|Closure|QueuedClosure|string $events, array|object|string|null $listener = null)
Register an event listener with the dispatcher.
This changes the wrapped dispatcher, which is usually the application's worker-shared dispatcher.
at line 251
void
observe(array|string $events, array|object|string $observer)
Register a passive event observer with the dispatcher.
This changes the wrapped dispatcher, which is usually the application's worker-shared dispatcher.
at line 259
bool
hasListeners(string $eventName)
Determine if a given event has listeners.
at line 295
void
push(string $event, mixed $payload = [])
Register an event and payload to be dispatched later.
at line 304
void
subscribe(object|string $subscriber)
Register an event subscriber with the dispatcher.
This changes the wrapped dispatcher, which is usually the application's worker-shared dispatcher.
at line 312
void
flush(string $event)
Flush a set of pushed events.
at line 319
mixed
dispatch(object|string $event, mixed $payload = [], bool $halt = false)
Fire an event and call the listeners.
at line 335
protected bool
shouldFakeEvent(string $eventName, mixed $payload)
Determine if an event should be faked or actually dispatched.
at line 356
protected void
fakeEvent(object|string $event, string $name, array $arguments)
Push the event onto the fake events array immediately or after the next database transaction.
at line 371
protected bool
shouldDispatchEvent(string $eventName, mixed $payload)
Determine whether an event should be dispatched or not.
at line 388
void
forget(string $event)
Remove a set of listeners from the dispatcher.
at line 395
void
forgetPushed()
Forget all events queued via push() in the current coroutine.
at line 402
mixed
until(object|string $event, mixed $payload = [])
Dispatch an event and call the listeners.
at line 410
array
dispatchedEvents()
Get the events that have been dispatched.
at line 418
mixed
__call(string $method, array $parameters)
Handle dynamic method calls to the dispatcher.