A free open source IT asset/license management system
Improve readability by extracting additional helpers
Marcus Moorebd4d3aa52bae
diff --git a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.phpindex e73d62a1cb..8d8bf3a6e0 100644--- a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php+++ b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php@@ -56,13 +56,7 @@ class SlackNotificationsUponCheckinTest extends TestCaseUser::factory()->create(),);- Notification::assertSentTo(- new AnonymousNotifiable,- CheckinAccessoryNotification::class,- function ($notification, $channels, $notifiable) {- return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;- }- );+ $this->assertSlackNotificationSent(CheckinAccessoryNotification::class);}public function testAccessoryCheckinDoesNotSendSlackNotificationWhenSettingDisabled()@@ -74,7 +68,7 @@ class SlackNotificationsUponCheckinTest extends TestCaseUser::factory()->create(),);- Notification::assertNotSentTo(new AnonymousNotifiable, CheckinAccessoryNotification::class);+ $this->assertNoSlackNotificationSent(CheckinAccessoryNotification::class);}/** @dataProvider assetCheckoutTargets */@@ -87,13 +81,7 @@ class SlackNotificationsUponCheckinTest extends TestCase$checkoutTarget(),);- Notification::assertSentTo(- new AnonymousNotifiable,- CheckinAssetNotification::class,- function ($notification, $channels, $notifiable) {- return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;- }- );+ $this->assertSlackNotificationSent(CheckinAssetNotification::class);}/** @dataProvider assetCheckoutTargets */@@ -106,7 +94,7 @@ class SlackNotificationsUponCheckinTest extends TestCase$checkoutTarget(),);- Notification::assertNotSentTo(new AnonymousNotifiable, CheckinAssetNotification::class);+ $this->assertNoSlackNotificationSent(CheckinAssetNotification::class);}public function testComponentCheckinDoesNotSendSlackNotification()@@ -141,13 +129,7 @@ class SlackNotificationsUponCheckinTest extends TestCase$checkoutTarget(),);- Notification::assertSentTo(- new AnonymousNotifiable,- CheckinLicenseSeatNotification::class,- function ($notification, $channels, $notifiable) {- return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;- }- );+ $this->assertSlackNotificationSent(CheckinLicenseSeatNotification::class);}/** @dataProvider licenseCheckoutTargets */@@ -160,7 +142,7 @@ class SlackNotificationsUponCheckinTest extends TestCase$checkoutTarget(),);- Notification::assertNotSentTo(new AnonymousNotifiable, CheckinLicenseSeatNotification::class);+ $this->assertNoSlackNotificationSent(CheckinLicenseSeatNotification::class);}private function fireCheckInEvent(Model $checkoutable, Model $target)@@ -172,4 +154,20 @@ 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, CheckinAccessoryNotification::class);+ }}