createOne(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a user is deleted, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testUserDeletedSendsDiscordNotification(): void { $user = User::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(UserDeleted::class); $user->delete(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a user is restored, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testUserRestoredSendsDiscordNotification(): void { $user = User::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(UserRestored::class); $user->restore(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a user is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testUserUpdatedSendsDiscordNotification(): void { $user = User::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(UserUpdated::class); $changes = User::factory()->makeOne(); $user->fill($changes->getAttributes()); $user->save(); Bus::assertDispatched(SendDiscordNotificationJob::class); } }