for(Anime::factory()) ->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(EntryCreated::class); AnimeThemeEntry::factory()->for($theme)->createOne(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an entry is deleted, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testEntryDeletedSendsDiscordNotification(): void { $entry = AnimeThemeEntry::factory() ->for(AnimeTheme::factory()->for(Anime::factory())) ->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(EntryDeleted::class); $entry->delete(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an entry is restored, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testEntryRestoredSendsDiscordNotification(): void { $entry = AnimeThemeEntry::factory() ->for(AnimeTheme::factory()->for(Anime::factory())) ->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(EntryRestored::class); $entry->restore(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an entry is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testEntryUpdatedSendsDiscordNotification(): void { $entry = AnimeThemeEntry::factory() ->for(AnimeTheme::factory()->for(Anime::factory())) ->createOne(); $changes = AnimeThemeEntry::factory() ->for(AnimeTheme::factory()->for(Anime::factory())) ->makeOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(EntryUpdated::class); $entry->fill($changes->getAttributes()); $entry->save(); Bus::assertDispatched(SendDiscordNotificationJob::class); } }