createOne(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an anime is deleted, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testAnimeDeletedSendsDiscordNotification(): void { $anime = Anime::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(AnimeDeleted::class); $anime->delete(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an anime is restored, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testAnimeRestoredSendsDiscordNotification(): void { $anime = Anime::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(AnimeRestored::class); $anime->restore(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an anime is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testAnimeUpdatedSendsDiscordNotification(): void { $anime = Anime::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(AnimeUpdated::class); $changes = Anime::factory()->makeOne(); $anime->fill($changes->getAttributes()); $anime->save(); Bus::assertDispatched(SendDiscordNotificationJob::class); } }