createOne(); $resource = ExternalResource::factory()->createOne(); Config::set(FlagConstants::ALLOW_DISCORD_NOTIFICATIONS_FLAG_QUALIFIED, true); Bus::fake(SendDiscordNotificationJob::class); $artist->resources()->attach($resource); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an Artist is detached from a Resource or vice versa, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testArtistResourceDeletedSendsDiscordNotification(): void { $artist = Artist::factory()->createOne(); $resource = ExternalResource::factory()->createOne(); $artist->resources()->attach($resource); Config::set(FlagConstants::ALLOW_DISCORD_NOTIFICATIONS_FLAG_QUALIFIED, true); Bus::fake(SendDiscordNotificationJob::class); $artist->resources()->detach($resource); Bus::assertDispatched(SendDiscordNotificationJob::class); } /** * When an Artist Resource pivot is updated, a SendDiscordNotification job shall be dispatched. * * @return void */ public function testArtistResourceUpdatedSendsDiscordNotification(): void { $artist = Artist::factory()->createOne(); $resource = ExternalResource::factory()->createOne(); $artistResource = ArtistResource::factory() ->for($artist, 'artist') ->for($resource, 'resource') ->createOne(); $changes = ArtistResource::factory() ->for($artist, 'artist') ->for($resource, 'resource') ->makeOne(); Config::set(FlagConstants::ALLOW_DISCORD_NOTIFICATIONS_FLAG_QUALIFIED, true); Bus::fake(SendDiscordNotificationJob::class); $artistResource->fill($changes->getAttributes()); $artistResource->save(); Bus::assertDispatched(SendDiscordNotificationJob::class); } }