class Illuminate / Support / Testing / Fakes / EventFake

EventFake

Implements

Uses

Properties

public

$dispatcher Dispatcher

The original event dispatcher.

Default: null
protected

$eventsToFake array

The event types that should be intercepted instead of dispatched.

Default: []
protected

$eventsToDispatch array

The event types that should be dispatched instead of intercepted.

Default: []
protected

$events array

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

Default: []

Methods

public

__construct ( Dispatcher $dispatcher , $eventsToFake ) : void

Create a new event fake instance.

Parameters

public

except ( $eventsToDispatch ) : $this

Specify the events that should be dispatched instead of faked.

Parameters

  • $eventsToDispatch array|string
public

assertListening ( $expectedEvent , $expectedListener ) : void

Assert if an event has a listener attached to it.

Parameters

  • $expectedEvent string
  • $expectedListener string|array
public

assertDispatched ( $event , $callback ) : void

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

Parameters

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

assertDispatchedTimes ( $event , $times ) : void

Assert if an event was dispatched a number of times.

Parameters

  • $event string
  • $times int
public

assertNotDispatched ( $event , $callback ) : void

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

Parameters

  • $event string|Closure
  • $callback callable|null
public

assertNothingDispatched ( ) : void

Assert that no events were dispatched.

public

dispatched ( $event , $callback ) : Illuminate\...\Collection

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

Parameters

  • $event string
  • $callback callable|null
public

hasDispatched ( $event ) : bool

Determine if the given event has been dispatched.

Parameters

  • $event string
public

listen ( $events , $listener ) : void

Register an event listener with the dispatcher.

Parameters

  • $events Closure |string|array
  • $listener mixed
public

hasListeners ( $eventName ) : bool

Determine if a given event has listeners.

Parameters

  • $eventName string
public

push ( $event , $payload ) : void

Register an event and payload to be dispatched later.

Parameters

  • $event string
  • $payload array
public

subscribe ( $subscriber ) : void

Register an event subscriber with the dispatcher.

Parameters

  • $subscriber object|string
public

flush ( $event ) : void

Flush a set of pushed events.

Parameters

  • $event string
public

dispatch ( $event , $payload , $halt ) : array|null

Fire an event and call the listeners.

Parameters

  • $event string|object
  • $payload mixed
  • $halt bool
protected

shouldFakeEvent ( $eventName , $payload ) : bool

Determine if an event should be faked or actually dispatched.

Parameters

  • $eventName string
  • $payload mixed
protected

shouldDispatchEvent ( $eventName , $payload ) : bool

Determine whether an event should be dispatched or not.

Parameters

  • $eventName string
  • $payload mixed
public

forget ( $event ) : void

Remove a set of listeners from the dispatcher.

Parameters

  • $event string
public

forgetPushed ( ) : void

Forget all of the queued listeners.

public

until ( $event , $payload ) : mixed

Dispatch an event and call the listeners.

Parameters

  • $event string|object
  • $payload mixed
public

__call ( $method , $parameters ) : mixed

Handle dynamic method calls to the dispatcher.

Parameters

  • $method string
  • $parameters array