settings->enableSlackWebhook(); event(new CheckoutableCheckedOut( Accessory::factory()->appleBtKeyboard()->create(), User::factory()->create(), User::factory()->superuser()->create(), '' )); Notification::assertSentTo( new AnonymousNotifiable, CheckoutAccessoryNotification::class, function ($notification, $channels, $notifiable) { return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint; } ); } public function testAccessoryCheckoutDoesNotSendSlackNotificationWhenSettingDisabled() { Notification::fake(); $this->settings->disableSlackWebhook(); event(new CheckoutableCheckedOut( Accessory::factory()->appleBtKeyboard()->create(), User::factory()->create(), User::factory()->superuser()->create(), '' )); Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutAccessoryNotification::class); } public function testAccessoryCheckinSendsSlackNotificationWhenSettingEnabled() { Notification::fake(); $this->settings->enableSlackWebhook(); event(new CheckoutableCheckedIn( Accessory::factory()->appleBtKeyboard()->create(), User::factory()->create(), User::factory()->superuser()->create(), '' )); Notification::assertSentTo( new AnonymousNotifiable, CheckinAccessoryNotification::class, function ($notification, $channels, $notifiable) { return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint; } ); } public function testAccessoryCheckinDoesNotSendSlackNotificationWhenSettingDisabled() { Notification::fake(); $this->settings->disableSlackWebhook(); event(new CheckoutableCheckedIn( Accessory::factory()->appleBtKeyboard()->create(), User::factory()->create(), User::factory()->superuser()->create(), '' )); Notification::assertNotSentTo(new AnonymousNotifiable, CheckinAccessoryNotification::class); } }