class Illuminate / Support / Testing / Fakes / EventFake
You are viewing an older version of the documentation. For the latest, please visit master documentation.

EventFake

Implements

Uses

Properties

protected

$dispatcher Dispatcher

The original event dispatcher.

Default: null
protected

$eventsToFake array

The event types that should be intercepted instead of dispatched.

Default: null
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

assertListening ( $expectedEvent , $expectedListener ) : void

Assert if an event has a listener attached to it.

Parameters

  • $expectedEvent string
  • $expectedListener string
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 ) : 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
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 ) : array|null

Dispatch an event and call the listeners.

Parameters

  • $event string|object
  • $payload mixed