[fn() => User::factory()->create()], 'License checked out to asset' => [fn() => Asset::factory()->laptopMbp()->create()], ]; } /** @dataProvider targets */ public function testLicenseCheckoutSendsSlackNotificationWhenSettingEnabled($checkoutTarget) { Notification::fake(); $this->settings->enableSlackWebhook(); event(new CheckoutableCheckedOut( LicenseSeat::factory()->create(), $checkoutTarget(), User::factory()->superuser()->create(), '' )); Notification::assertSentTo( new AnonymousNotifiable, CheckoutLicenseSeatNotification::class, function ($notification, $channels, $notifiable) { return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint; } ); } /** @dataProvider targets */ public function testLicenseCheckoutDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget) { Notification::fake(); $this->settings->disableSlackWebhook(); event(new CheckoutableCheckedOut( LicenseSeat::factory()->create(), $checkoutTarget(), User::factory()->superuser()->create(), '' )); Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutLicenseSeatNotification::class); } /** @dataProvider targets */ public function testLicenseCheckinSendsSlackNotificationWhenSettingEnabled($checkoutTarget) { Notification::fake(); $this->settings->enableSlackWebhook(); event(new CheckoutableCheckedIn( LicenseSeat::factory()->create(), $checkoutTarget(), User::factory()->superuser()->create(), '' )); Notification::assertSentTo( new AnonymousNotifiable, CheckinLicenseSeatNotification::class, function ($notification, $channels, $notifiable) { return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint; } ); } /** @dataProvider targets */ public function testLicenseCheckinDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget) { Notification::fake(); $this->settings->disableSlackWebhook(); event(new CheckoutableCheckedIn( LicenseSeat::factory()->create(), $checkoutTarget(), User::factory()->superuser()->create(), '' )); Notification::assertNotSentTo(new AnonymousNotifiable, CheckinLicenseSeatNotification::class); } }