createOne(); Event::assertDispatched(ExternalProfileCreated::class); } /** * When a profile is deleted, a ExternalProfileDeleted event shall be dispatched. * * @return void */ public function testExternalProfileDeletedEventDispatched(): void { $profile = ExternalProfile::factory()->createOne(); $profile->delete(); Event::assertDispatched(ExternalProfileDeleted::class); } /** * When a profile is restored, a ExternalProfileRestored event shall be dispatched. * * @return void */ public function testExternalProfileRestoredEventDispatched(): void { $profile = ExternalProfile::factory()->createOne(); $profile->restore(); Event::assertDispatched(ExternalProfileRestored::class); } /** * When a profile is restored, a ExternalProfileUpdated 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 testExternalProfileRestoresQuietly(): void { $profile = ExternalProfile::factory()->createOne(); $profile->restore(); Event::assertNotDispatched(ExternalProfileUpdated::class); } /** * When a profile is updated, a ExternalProfileUpdated event shall be dispatched. * * @return void */ public function testExternalProfileUpdatedEventDispatched(): void { $profile = ExternalProfile::factory()->createOne(); $changes = ExternalProfile::factory()->makeOne(); $profile->fill($changes->getAttributes()); $profile->save(); Event::assertDispatched(ExternalProfileUpdated::class); } /** * The ExternalProfileUpdated event shall contain embed fields. * * @return void */ public function testExternalProfileUpdatedEventEmbedFields(): void { $profile = ExternalProfile::factory()->createOne(); $changes = ExternalProfile::factory()->makeOne(); $profile->fill($changes->getAttributes()); $profile->save(); Event::assertDispatched(ExternalProfileUpdated::class, function (ExternalProfileUpdated $event) { $message = $event->getDiscordMessage(); return ! empty(Arr::get($message->embed, 'fields')); }); } }