Skip to content

Commit

Permalink
[11.x] add function to get faked events (laravel#50905)
Browse files Browse the repository at this point in the history
* add function to get faked events

this function will return an array of all Events that have been faked.

this can be helpful when originally writing the tests to get a grasp of which events you may need to intercept.

both the `QueueFake` and `NotificationFake` have similar methods to let you see what has been intercepted by the fake.

https://github.com/laravel/framework/blob/11.x/src/Illuminate/Support/Testing/Fakes/QueueFake.php#L512
https://github.com/laravel/framework/blob/11.x/src/Illuminate/Support/Testing/Fakes/NotificationFake.php#L357

* Update EventFake.php

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
browner12 and taylorotwell authored Apr 5, 2024
1 parent 6315391 commit b206204
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Illuminate/Support/Testing/Fakes/EventFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,16 @@ public function until($event, $payload = [])
return $this->dispatch($event, $payload, true);
}

/**
* Get the events that have been dispatched.
*
* @return array
*/
public function dispatchedEvents()
{
return $this->events;
}

/**
* Handle dynamic method calls to the dispatcher.
*
Expand Down

0 comments on commit b206204

Please sign in to comment.