Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Add Notification testing helpers #49675

Closed
wants to merge 4 commits into from
Closed

[10.x] Add Notification testing helpers #49675

wants to merge 4 commits into from

Conversation

xurshudyan
Copy link
Contributor

This pull request introduces a new testing helpers, specifically focusing on detecting if a notification has been queued. Currently, Laravel provides extensive testing helpers for notifications, but lacks a direct method to determine if a notification has been queued.

class InvoicePaid extends Notification implements ShouldQueue
{
    use Queueable;
}


$user = User::first();

$user->notify(new InvoicePaid());

Notification::assertNothingQueued();

Notification::assertQueued($user, InvoicePaid::class);

Notification::assertQueuedCount(1);

Notification::assertNotQueued($user, OrderShippedNotification::class);

@xurshudyan xurshudyan marked this pull request as draft January 14, 2024 11:36
@xurshudyan xurshudyan marked this pull request as ready for review January 14, 2024 12:28
@taylorotwell
Copy link
Member

I'm not sure we really need this atm. You can assert that the notification was sent. If you want to see if it is queued you can just assert that the notification implements ShouldQueue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants