Skip to content

Conversation

@Ayoub-Mabrouk
Copy link
Contributor

The test was passing by accident due to two bugs that masked each other:

  1. Wrong config key: Used 'failed-job-monitor.callback' instead of 'failed-job-monitor.notificationFilter', causing the filter to never execute (config returned null, is_callable(null) = false, so default behavior sent notification).

  2. Wrong notification class: Asserted that AnotherNotification::class was not sent, but the default notification class is Notification::class. Since the filter didn't run, Notification::class was sent, and the test checked for AnotherNotification::class (which wasn't sent), so it passed incorrectly.

The test appeared to work but wasn't actually validating the filter functionality. When the filter should return false (empty exception message), the notification should not be sent, but the test wasn't verifying this correctly.

Changes:

  • Use correct config key 'failed-job-monitor.notificationFilter'
  • Assert against the correct notification class Notification::class

Now the test properly validates that when notificationFilter returns false, no notification is sent to the default Notifiable with the
default Notification class.

The test was passing by accident due to two bugs that masked each other:

1. Wrong config key: Used 'failed-job-monitor.callback' instead of
   'failed-job-monitor.notificationFilter', causing the filter to never
   execute (config returned null, is_callable(null) = false, so default
   behavior sent notification).

2. Wrong notification class: Asserted that AnotherNotification::class
   was not sent, but the default notification class is Notification::class.
   Since the filter didn't run, Notification::class was sent, and the
   test checked for AnotherNotification::class (which wasn't sent), so
   it passed incorrectly.

The test appeared to work but wasn't actually validating the filter
functionality. When the filter should return false (empty exception
message), the notification should not be sent, but the test wasn't
verifying this correctly.

Changes:
- Use correct config key 'failed-job-monitor.notificationFilter'
- Assert against the correct notification class Notification::class

Now the test properly validates that when notificationFilter returns
false, no notification is sent to the default Notifiable with the
default Notification class.
@freekmurze freekmurze merged commit 618718a into spatie:main Jan 5, 2026
11 checks passed
@freekmurze
Copy link
Member

Thanks!

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