createOne(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a profile is deleted, a SendDiscordNotification job shall not be dispatched. * * @return void */ public function testExternalProfileDeletedSendsDiscordNotification(): void { $profile = ExternalProfile::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ExternalProfileDeleted::class); $profile->delete(); Bus::assertNotDispatched(SendDiscordNotificationJob::class); } /** * When a profile is restored, a SendDiscordNotification job shall not be dispatched. * * @return void */ public function testExternalProfileRestoredSendsDiscordNotification(): void { $profile = ExternalProfile::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ExternalProfileRestored::class); $profile->restore(); Bus::assertNotDispatched(SendDiscordNotificationJob::class); } /** * When a profile is updated, a SendDiscordNotification job shall not be dispatched. * * @return void */ public function testExternalProfileUpdatedSendsDiscordNotification(): void { $profile = ExternalProfile::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ExternalProfileUpdated::class); $changes = ExternalProfile::factory()->makeOne(); $profile->fill($changes->getAttributes()); $profile->save(); Bus::assertNotDispatched(SendDiscordNotificationJob::class); } }