createOne(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an image is deleted, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testImageDeletedSendsDiscordNotification(): void { $image = Image::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ImageDeleted::class); $image->delete(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an image is restored, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testImageRestoredSendsDiscordNotification(): void { $image = Image::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ImageRestored::class); $image->restore(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an image is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testImageUpdatedSendsDiscordNotification(): void { $image = Image::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ImageUpdated::class); $changes = Image::factory()->makeOne(); $image->fill($changes->getAttributes()); $image->save(); Bus::assertDispatched(SendDiscordNotificationJob::class); } }