createOne(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a script is deleted, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testVideoDeletedSendsDiscordNotification(): void { $script = VideoScript::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(VideoScriptDeleted::class); $script->delete(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a script is restored, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testVideoRestoredSendsDiscordNotification(): void { $script = VideoScript::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(VideoScriptRestored::class); $script->restore(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a script is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testVideoUpdatedSendsDiscordNotification(): void { $script = VideoScript::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(VideoScriptUpdated::class); $changes = VideoScript::factory()->makeOne(); $script->fill($changes->getAttributes()); $script->save(); Bus::assertDispatched(SendDiscordNotificationJob::class); } }