Skip to content

Commit

Permalink
Documented new feature (#7920)
Browse files Browse the repository at this point in the history
* Update mocking.md

* formatting

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
yoeriboven and taylorotwell authored May 4, 2022
1 parent 8222b17 commit e3ccc42
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions mocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,18 +479,13 @@ You may pass a closure to the `assertSentTo` or `assertNotSentTo` methods in ord
<a name="on-demand-notifications"></a>
#### On-Demand Notifications

If the code you are testing sends [on-demand notifications](/docs/{{version}}/notifications#on-demand-notifications), you will need to assert that the notification was sent to an `Illuminate\Notifications\AnonymousNotifiable` instance:
If the code you are testing sends [on-demand notifications](/docs/{{version}}/notifications#on-demand-notifications), you can test that the on-demand notification was sent via the `assertSentOnDemand` method:

use Illuminate\Notifications\AnonymousNotifiable;
Notification::assertSentOnDemand(OrderShipped::class);

Notification::assertSentTo(
new AnonymousNotifiable, OrderShipped::class
);
By passing a closure as the second argument to the `assertSentOnDemand` method, you may determine if an on-demand notification was sent to the correct "route" address:

By passing a closure as the third argument to the notification assertion methods, you may determine if an on-demand notification was sent to the correct "route" address:

Notification::assertSentTo(
new AnonymousNotifiable,
Notification::assertSentOnDemand(
OrderShipped::class,
function ($notification, $channels, $notifiable) use ($user) {
return $notifiable->routes['mail'] === $user->email;
Expand Down

0 comments on commit e3ccc42

Please sign in to comment.