createOne(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a resource is deleted, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testResourceDeletedSendsDiscordNotification(): void { $resource = ExternalResource::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ExternalResourceDeleted::class); $resource->delete(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a resource is restored, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testResourceRestoredSendsDiscordNotification(): void { $resource = ExternalResource::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ExternalResourceRestored::class); $resource->restore(); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When a resource is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testResourceUpdatedSendsDiscordNotification(): void { $resource = ExternalResource::factory()->createOne(); Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS); Bus::fake(SendDiscordNotificationJob::class); Event::fakeExcept(ExternalResourceUpdated::class); $changes = ExternalResource::factory()->makeOne(); $resource->fill($changes->getAttributes()); $resource->save(); Bus::assertDispatched(SendDiscordNotificationJob::class); } }