W3cubDocs

/Laravel 8

EventFake

class EventFake implements Dispatcher (View source)

Traits

ReflectsClosures

Properties

protected Dispatcher $dispatcher The original event dispatcher.
protected array $eventsToFake The event types that should be intercepted instead of dispatched.
protected array $events All of the events that have been intercepted keyed by type.

Methods

array closureParameterTypes(Closure $closure)

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

from ReflectsClosures
string firstClosureParameterType(Closure $closure)

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

from ReflectsClosures
void __construct(Dispatcher $dispatcher, array|string $eventsToFake = [])

Create a new event fake instance.

void assertDispatched(string|Closure $event, callable|int|null $callback = null)

Assert if an event was dispatched based on a truth-test callback.

void assertDispatchedTimes(string $event, int $times = 1)

Assert if an event was dispatched a number of times.

void assertNotDispatched(string|Closure $event, callable|null $callback = null)

Determine if an event was dispatched based on a truth-test callback.

Collection dispatched(string $event, callable|null $callback = null)

Get all of the events matching a truth-test callback.

bool hasDispatched(string $event)

Determine if the given event has been dispatched.

void listen(Closure|string|array $events, Closure|string|null $listener = null)

Register an event listener with the dispatcher.

bool hasListeners(string $eventName)

Determine if a given event has listeners.

void push(string $event, array $payload = [])

Register an event and payload to be dispatched later.

void subscribe(object|string $subscriber)

Register an event subscriber with the dispatcher.

void flush(string $event)

Flush a set of pushed events.

array|null dispatch(string|object $event, mixed $payload = [], bool $halt = false)

Fire an event and call the listeners.

bool shouldFakeEvent(string $eventName, mixed $payload)

Determine if an event should be faked or actually dispatched.

void forget(string $event)

Remove a set of listeners from the dispatcher.

void forgetPushed()

Forget all of the queued listeners.

array|null until(string|object $event, mixed $payload = [])

Dispatch an event and call the listeners.

Details

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

protected string firstClosureParameterType(Closure $closure)

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

Parameters

Closure $closure

Return Value

string

Exceptions

RuntimeException

void __construct(Dispatcher $dispatcher, array|string $eventsToFake = [])

Create a new event fake instance.

Parameters

Dispatcher $dispatcher
array|string $eventsToFake

Return Value

void

void assertDispatched(string|Closure $event, callable|int|null $callback = null)

Assert if an event was dispatched based on a truth-test callback.

Parameters

string|Closure $event
callable|int|null $callback

Return Value

void

void assertDispatchedTimes(string $event, int $times = 1)

Assert if an event was dispatched a number of times.

Parameters

string $event
int $times

Return Value

void

void assertNotDispatched(string|Closure $event, callable|null $callback = null)

Determine if an event was dispatched based on a truth-test callback.

Parameters

string|Closure $event
callable|null $callback

Return Value

void

Collection dispatched(string $event, callable|null $callback = null)

Get all of the events matching a truth-test callback.

Parameters

string $event
callable|null $callback

Return Value

Collection

bool hasDispatched(string $event)

Determine if the given event has been dispatched.

Parameters

string $event

Return Value

bool

void listen(Closure|string|array $events, Closure|string|null $listener = null)

Register an event listener with the dispatcher.

Parameters

Closure|string|array $events
Closure|string|null $listener

Return Value

void

bool hasListeners(string $eventName)

Determine if a given event has listeners.

Parameters

string $eventName

Return Value

bool

void push(string $event, array $payload = [])

Register an event and payload to be dispatched later.

Parameters

string $event
array $payload

Return Value

void

void subscribe(object|string $subscriber)

Register an event subscriber with the dispatcher.

Parameters

object|string $subscriber

Return Value

void

void flush(string $event)

Flush a set of pushed events.

Parameters

string $event

Return Value

void

array|null dispatch(string|object $event, mixed $payload = [], bool $halt = false)

Fire an event and call the listeners.

Parameters

string|object $event
mixed $payload
bool $halt

Return Value

array|null

protected bool shouldFakeEvent(string $eventName, mixed $payload)

Determine if an event should be faked or actually dispatched.

Parameters

string $eventName
mixed $payload

Return Value

bool

void forget(string $event)

Remove a set of listeners from the dispatcher.

Parameters

string $event

Return Value

void

void forgetPushed()

Forget all of the queued listeners.

Return Value

void

array|null until(string|object $event, mixed $payload = [])

Dispatch an event and call the listeners.

Parameters

string|object $event
mixed $payload

Return Value

array|null

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Support/Testing/Fakes/EventFake.html