Documentation

EventFake
in package
implements Dispatcher

Interfaces, Classes and Traits

Dispatcher

Table of Contents

$dispatcher  : Dispatcher
The original event dispatcher.
$events  : array<string|int, mixed>
All of the events that have been intercepted keyed by type.
$eventsToFake  : array<string|int, mixed>
The event types that should be intercepted instead of dispatched.
__construct()  : void
Create a new event fake instance.
assertDispatched()  : void
Assert if an event was dispatched based on a truth-test callback.
assertDispatchedTimes()  : void
Assert if a event was dispatched a number of times.
assertNotDispatched()  : void
Determine if an event was dispatched based on a truth-test callback.
dispatch()  : array<string|int, mixed>|null
Fire an event and call the listeners.
dispatched()  : Collection
Get all of the events matching a truth-test callback.
fire()  : array<string|int, mixed>|null
Fire an event and call the listeners.
flush()  : void
Flush a set of pushed events.
forget()  : void
Remove a set of listeners from the dispatcher.
forgetPushed()  : void
Forget all of the queued listeners.
hasDispatched()  : bool
Determine if the given event has been dispatched.
hasListeners()  : bool
Determine if a given event has listeners.
listen()  : void
Register an event listener with the dispatcher.
push()  : void
Register an event and payload to be dispatched later.
subscribe()  : void
Register an event subscriber with the dispatcher.
until()  : void
Dispatch an event and call the listeners.
shouldFakeEvent()  : bool
Determine if an event should be faked or actually dispatched.

Properties

$events

All of the events that have been intercepted keyed by type.

protected array<string|int, mixed> $events = []

$eventsToFake

The event types that should be intercepted instead of dispatched.

protected array<string|int, mixed> $eventsToFake

Methods

__construct()

Create a new event fake instance.

public __construct(Dispatcher $dispatcher[, array<string|int, mixed>|string $eventsToFake = [] ]) : void
Parameters
$dispatcher : Dispatcher
$eventsToFake : array<string|int, mixed>|string = []
Return values
void

assertDispatched()

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

public assertDispatched(string $event[, callable|int|null $callback = null ]) : void
Parameters
$event : string
$callback : callable|int|null = null
Return values
void

assertDispatchedTimes()

Assert if a event was dispatched a number of times.

public assertDispatchedTimes(string $event[, int $times = 1 ]) : void
Parameters
$event : string
$times : int = 1
Return values
void

assertNotDispatched()

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

public assertNotDispatched(string $event[, callable|null $callback = null ]) : void
Parameters
$event : string
$callback : callable|null = null
Return values
void

dispatch()

Fire an event and call the listeners.

public dispatch(string|object $event[, mixed $payload = [] ][, bool $halt = false ]) : array<string|int, mixed>|null
Parameters
$event : string|object
$payload : mixed = []
$halt : bool = false
Return values
array<string|int, mixed>|null

dispatched()

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

public dispatched(string $event[, callable|null $callback = null ]) : Collection
Parameters
$event : string
$callback : callable|null = null
Return values
Collection

fire()

Fire an event and call the listeners.

public fire(string|object $event[, mixed $payload = [] ][, bool $halt = false ]) : array<string|int, mixed>|null
Parameters
$event : string|object
$payload : mixed = []
$halt : bool = false
Return values
array<string|int, mixed>|null

flush()

Flush a set of pushed events.

public flush(string $event) : void
Parameters
$event : string
Return values
void

forget()

Remove a set of listeners from the dispatcher.

public forget(string $event) : void
Parameters
$event : string
Return values
void

forgetPushed()

Forget all of the queued listeners.

public forgetPushed() : void
Return values
void

hasDispatched()

Determine if the given event has been dispatched.

public hasDispatched(string $event) : bool
Parameters
$event : string
Return values
bool

hasListeners()

Determine if a given event has listeners.

public hasListeners(string $eventName) : bool
Parameters
$eventName : string
Return values
bool

listen()

Register an event listener with the dispatcher.

public listen(string|array<string|int, mixed> $events, mixed $listener) : void
Parameters
$events : string|array<string|int, mixed>
$listener : mixed
Return values
void

push()

Register an event and payload to be dispatched later.

public push(string $event[, array<string|int, mixed> $payload = [] ]) : void
Parameters
$event : string
$payload : array<string|int, mixed> = []
Return values
void

subscribe()

Register an event subscriber with the dispatcher.

public subscribe(object|string $subscriber) : void
Parameters
$subscriber : object|string
Return values
void

until()

Dispatch an event and call the listeners.

public until(string|object $event[, mixed $payload = [] ]) : void
Parameters
$event : string|object
$payload : mixed = []
Return values
void

shouldFakeEvent()

Determine if an event should be faked or actually dispatched.

protected shouldFakeEvent(string $eventName) : bool
Parameters
$eventName : string
Return values
bool

Search results