createOne(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a song is deleted, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testSongDeletedSendsDiscordNotification(): void { $song = Song::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(SongDeleted::class); $song->delete(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a song is restored, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testSongRestoredSendsDiscordNotification(): void { $song = Song::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(SongRestored::class); $song->restore(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a song is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testSongUpdatedSendsDiscordNotification(): void { $song = Song::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(SongUpdated::class); $changes = Song::factory()->makeOne(); $song->fill($changes->getAttributes()); $song->save(); Bus::assertDispatched(SendDiscordNotificationJob::class); } }