trait MocksApplicationServices (View source)

Properties

protected array $firedEvents

All of the fired events.

protected array $firedModelEvents

All of the fired model events.

protected array $dispatchedJobs

All of the dispatched jobs.

protected array $dispatchedNotifications

All of the dispatched notifications.

Methods

$this
expectsEvents(array|string $events)

Specify a list of events that should be fired for the given operation.

$this
doesntExpectEvents(array|string $events)

Specify a list of events that should not be fired for the given operation.

$this
withoutEvents()

Mock the event dispatcher so all events are silenced and collected.

array
getFiredEvents(array $events)

Filter the given events against the fired events.

$this
expectsJobs(array|string $jobs)

Specify a list of jobs that should be dispatched for the given operation.

$this
doesntExpectJobs(array|string $jobs)

Specify a list of jobs that should not be dispatched for the given operation.

$this
withoutJobs()

Mock the job dispatcher so all jobs are silenced and collected.

array
getDispatchedJobs(array $jobs)

Filter the given jobs against the dispatched jobs.

array
getDispatched(array $classes, array $dispatched)

Filter the given classes against an array of dispatched classes.

bool
wasDispatched(string $needle, array $haystack)

Check if the given class exists in an array of dispatched classes.

$this
withoutNotifications()

Mock the notification dispatcher so all notifications are silenced.

$this
expectsNotification(mixed $notifiable, string $notification)

Specify a notification that is expected to be dispatched.

Details

$this expectsEvents(array|string $events)

Specify a list of events that should be fired for the given operation.

These events will be mocked, so that handlers will not actually be executed.

Parameters

array|string $events

Return Value

$this

Exceptions

Exception

$this doesntExpectEvents(array|string $events)

Specify a list of events that should not be fired for the given operation.

These events will be mocked, so that handlers will not actually be executed.

Parameters

array|string $events

Return Value

$this

protected $this withoutEvents()

Mock the event dispatcher so all events are silenced and collected.

Return Value

$this

protected array getFiredEvents(array $events)

Filter the given events against the fired events.

Parameters

array $events

Return Value

array

protected $this expectsJobs(array|string $jobs)

Specify a list of jobs that should be dispatched for the given operation.

These jobs will be mocked, so that handlers will not actually be executed.

Parameters

array|string $jobs

Return Value

$this

protected $this doesntExpectJobs(array|string $jobs)

Specify a list of jobs that should not be dispatched for the given operation.

These jobs will be mocked, so that handlers will not actually be executed.

Parameters

array|string $jobs

Return Value

$this

protected $this withoutJobs()

Mock the job dispatcher so all jobs are silenced and collected.

Return Value

$this

protected array getDispatchedJobs(array $jobs)

Filter the given jobs against the dispatched jobs.

Parameters

array $jobs

Return Value

array

protected array getDispatched(array $classes, array $dispatched)

Filter the given classes against an array of dispatched classes.

Parameters

array $classes
array $dispatched

Return Value

array

protected bool wasDispatched(string $needle, array $haystack)

Check if the given class exists in an array of dispatched classes.

Parameters

string $needle
array $haystack

Return Value

bool

protected $this withoutNotifications()

Mock the notification dispatcher so all notifications are silenced.

Return Value

$this

protected $this expectsNotification(mixed $notifiable, string $notification)

Specify a notification that is expected to be dispatched.

Parameters

mixed $notifiable
string $notification

Return Value

$this