MocksApplicationServices
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.
$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.
protected $this withoutEvents()
Mock the event dispatcher so all events are silenced and collected.
protected array getFiredEvents(array $events)
Filter the given events against the fired events.
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.
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.
protected $this withoutJobs()
Mock the job dispatcher so all jobs are silenced and collected.
protected array getDispatchedJobs(array $jobs)
Filter the given jobs against the dispatched jobs.
protected array getDispatched(array $classes, array $dispatched)
Filter the given classes against an array of dispatched classes.
protected bool wasDispatched(string $needle, array $haystack)
Check if the given class exists in an array of dispatched classes.
protected $this withoutNotifications()
Mock the notification dispatcher so all notifications are silenced.
protected $this expectsNotification(mixed $notifiable, string $notification)
Specify a notification that is expected to be dispatched.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Foundation/Testing/Concerns/MocksApplicationServices.html