createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ThemeCreated::class); AnimeTheme::factory()->for($anime)->createOne(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a theme is deleted, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testThemeDeletedSendsDiscordNotification(): void { $theme = AnimeTheme::factory() ->for(Anime::factory()) ->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ThemeDeleted::class); $theme->delete(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a theme is restored, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testThemeRestoredSendsDiscordNotification(): void { $theme = AnimeTheme::factory() ->for(Anime::factory()) ->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ThemeRestored::class); $theme->restore(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a theme is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testThemeUpdatedSendsDiscordNotification(): void { $theme = AnimeTheme::factory() ->for(Anime::factory()) ->createOne(); $changes = AnimeTheme::factory() ->for(Anime::factory()) ->makeOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ThemeUpdated::class); $theme->fill($changes->getAttributes()); $theme->save(); Bus::assertDispatched(SendDiscordNotificationJob::class); } }