createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(TrackCreated::class); PlaylistTrack::factory() ->for($playlist) ->createOne(); Bus::assertNotDispatched(SendDiscordNotificationJob::class); } /** * When a track is deleted, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testPlaylistDeletedSendsDiscordNotification(): void { $playlist = Playlist::factory()->createOne(); $track = PlaylistTrack::factory() ->for($playlist) ->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(TrackDeleted::class); $track->delete(); Bus::assertNotDispatched(SendDiscordNotificationJob::class); } /** * When a track is restored, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testPlaylistRestoredSendsDiscordNotification(): void { $playlist = Playlist::factory()->createOne(); $track = PlaylistTrack::factory() ->for($playlist) ->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(TrackRestored::class); $track->restore(); Bus::assertNotDispatched(SendDiscordNotificationJob::class); } /** * When a track is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testPlaylistUpdatedSendsDiscordNotification(): void { $playlist = Playlist::factory()->createOne(); $track = PlaylistTrack::factory() ->for($playlist) ->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(TrackUpdated::class); $changes = array_merge( PlaylistTrack::factory()->raw(), [PlaylistTrack::ATTRIBUTE_VIDEO => Video::factory()->createOne()->getKey()], ); $track->fill($changes); $track->save(); Bus::assertNotDispatched(SendDiscordNotificationJob::class); } }