diff --git a/mocking.md b/mocking.md index 0586429b659..fa65530a1a3 100644 --- a/mocking.md +++ b/mocking.md @@ -479,18 +479,13 @@ You may pass a closure to the `assertSentTo` or `assertNotSentTo` methods in ord #### 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;