createOne(); Event::assertDispatched(VideoCreated::class); } /** * When a Video is deleted, a VideoDeleted event shall be dispatched. * * @return void */ public function testVideoDeletedEventDispatched(): void { $video = Video::factory()->createOne(); $video->delete(); Event::assertDispatched(VideoDeleted::class); } /** * When a Video is restored, a VideoRestored event shall be dispatched. * * @return void */ public function testVideoRestoredEventDispatched(): void { $video = Video::factory()->createOne(); $video->restore(); Event::assertDispatched(VideoRestored::class); } /** * When a Video is restored, a VideoUpdated 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 testVideoRestoresQuietly(): void { $video = Video::factory()->createOne(); $video->restore(); Event::assertNotDispatched(VideoUpdated::class); } /** * When a Video is updated, a VideoUpdated event shall be dispatched. * * @return void */ public function testVideoUpdatedEventDispatched(): void { $video = Video::factory()->createOne(); $changes = Video::factory()->makeOne(); $video->fill($changes->getAttributes()); $video->save(); Event::assertDispatched(VideoUpdated::class); } /** * The VideoUpdated event shall contain embed fields. * * @return void */ public function testVideoUpdatedEventEmbedFields(): void { $video = Video::factory()->createOne(); $changes = Video::factory()->makeOne(); $video->fill($changes->getAttributes()); $video->save(); Event::assertDispatched(VideoUpdated::class, function (VideoUpdated $event) { $message = $event->getDiscordMessage(); return ! empty(Arr::get($message->embed, 'fields')); }); } }