diff --git a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php index c03d9a30aa..372f212c03 100644 --- a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php +++ b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php @@ -8,19 +8,19 @@ use App\Models\Asset; use App\Models\Component; use App\Models\LicenseSeat; use App\Models\Location; -use App\Models\Setting; use App\Models\User; use App\Notifications\CheckinAccessoryNotification; use App\Notifications\CheckinAssetNotification; use App\Notifications\CheckinLicenseSeatNotification; use Illuminate\Database\Eloquent\Model; -use Illuminate\Notifications\AnonymousNotifiable; use Illuminate\Support\Facades\Notification; +use Tests\Support\AssertsAgainstSlackNotifications; use Tests\Support\InteractsWithSettings; use Tests\TestCase; class SlackNotificationsUponCheckinTest extends TestCase { + use AssertsAgainstSlackNotifications; use InteractsWithSettings; protected function setUp(): void @@ -154,20 +154,4 @@ class SlackNotificationsUponCheckinTest extends TestCase '' )); } - - private function assertSlackNotificationSent(string $notificationClass) - { - Notification::assertSentTo( - new AnonymousNotifiable, - $notificationClass, - function ($notification, $channels, $notifiable) { - return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint; - } - ); - } - - private function assertNoSlackNotificationSent(string $notificationClass) - { - Notification::assertNotSentTo(new AnonymousNotifiable, $notificationClass); - } } diff --git a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php index 739c7e96b8..58570f90e7 100644 --- a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php +++ b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php @@ -9,20 +9,20 @@ use App\Models\Component; use App\Models\Consumable; use App\Models\LicenseSeat; use App\Models\Location; -use App\Models\Setting; use App\Models\User; use App\Notifications\CheckoutAccessoryNotification; use App\Notifications\CheckoutAssetNotification; use App\Notifications\CheckoutConsumableNotification; use App\Notifications\CheckoutLicenseSeatNotification; use Illuminate\Database\Eloquent\Model; -use Illuminate\Notifications\AnonymousNotifiable; use Illuminate\Support\Facades\Notification; +use Tests\Support\AssertsAgainstSlackNotifications; use Tests\Support\InteractsWithSettings; use Tests\TestCase; class SlackNotificationsUponCheckoutTest extends TestCase { + use AssertsAgainstSlackNotifications; use InteractsWithSettings; protected function setUp(): void @@ -170,20 +170,4 @@ class SlackNotificationsUponCheckoutTest extends TestCase '', )); } - - private function assertSlackNotificationSent(string $notificationClass) - { - Notification::assertSentTo( - new AnonymousNotifiable, - $notificationClass, - function ($notification, $channels, $notifiable) { - return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint; - } - ); - } - - private function assertNoSlackNotificationSent(string $notificationClass) - { - Notification::assertNotSentTo(new AnonymousNotifiable, $notificationClass); - } } diff --git a/tests/Support/AssertsAgainstSlackNotifications.php b/tests/Support/AssertsAgainstSlackNotifications.php new file mode 100644 index 0000000000..11e6beea2d --- /dev/null +++ b/tests/Support/AssertsAgainstSlackNotifications.php @@ -0,0 +1,26 @@ +routes['slack'] === Setting::getSettings()->webhook_endpoint; + } + ); + } + + public function assertNoSlackNotificationSent(string $notificationClass) + { + Notification::assertNotSentTo(new AnonymousNotifiable, $notificationClass); + } +}