createOne(); Event::assertDispatched(ArtistCreated::class); } /** * When an Artist is deleted, an ArtistDeleted event shall be dispatched. * * @return void */ public function testArtistDeletedEventDispatched(): void { $artist = Artist::factory()->createOne(); $artist->delete(); Event::assertDispatched(ArtistDeleted::class); } /** * When an Artist is restored, an ArtistRestored event shall be dispatched. * * @return void */ public function testArtistRestoredEventDispatched(): void { $artist = Artist::factory()->createOne(); $artist->restore(); Event::assertDispatched(ArtistRestored::class); } /** * When an Artist is restored, an ArtistUpdated event shall not be dispatched. * Note: This is a customization that overrides default framework behavior. * An updated event is fired on restore. * * @return void */ public function testArtistRestoresQuietly(): void { $artist = Artist::factory()->createOne(); $artist->restore(); Event::assertNotDispatched(ArtistUpdated::class); } /** * When an Artist is updated, an ArtistUpdated event shall be dispatched. * * @return void */ public function testArtistUpdatedEventDispatched(): void { $artist = Artist::factory()->createOne(); $changes = Artist::factory()->makeOne(); $artist->fill($changes->getAttributes()); $artist->save(); Event::assertDispatched(ArtistUpdated::class); } /** * The ArtistUpdated event shall contain embed fields. * * @return void */ public function testArtistUpdatedEventEmbedFields(): void { $artist = Artist::factory()->createOne(); $changes = Artist::factory()->makeOne(); $artist->fill($changes->getAttributes()); $artist->save(); Event::assertDispatched(ArtistUpdated::class, function (ArtistUpdated $event) { $message = $event->getDiscordMessage(); return ! empty(Arr::get($message->embed, 'fields')); }); } }