createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(SynonymCreated::class); AnimeSynonym::factory()->for($anime)->createOne(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a synonym is deleted, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testSynonymDeletedSendsDiscordNotification(): void { $synonym = AnimeSynonym::factory() ->for(Anime::factory()) ->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(SynonymDeleted::class); $synonym->delete(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a synonym is restored, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testSynonymRestoredSendsDiscordNotification(): void { $synonym = AnimeSynonym::factory() ->for(Anime::factory()) ->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(SynonymRestored::class); $synonym->restore(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a synonym is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testSynonymUpdatedSendsDiscordNotification(): void { $synonym = AnimeSynonym::factory() ->for(Anime::factory()) ->createOne(); $changes = AnimeSynonym::factory() ->for(Anime::factory()) ->makeOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(SynonymUpdated::class); $synonym->fill($changes->getAttributes()); $synonym->save(); Bus::assertDispatched(SendDiscordNotificationJob::class); } }