create(); Event::assertDispatched(DumpCreated::class); } /** * When a Dump is deleted, a DumpDeleted event shall be dispatched. * * @return void */ public function testDumpDeletedEventDispatched(): void { $dump = Dump::factory()->create(); $dump->delete(); Event::assertDispatched(DumpDeleted::class); } /** * When a Dump is restored, a DumpRestored event shall be dispatched. * * @return void */ public function testDumpRestoredEventDispatched(): void { $dump = Dump::factory()->createOne(); $dump->restore(); Event::assertDispatched(DumpRestored::class); } /** * When a Dump is restored, a DumpUpdated 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 testDumpRestoresQuietly(): void { $dump = Dump::factory()->createOne(); $dump->restore(); Event::assertNotDispatched(DumpUpdated::class); } /** * When a Dump is updated, a DumpUpdated event shall be dispatched. * * @return void */ public function testDumpUpdatedEventDispatched(): void { $dump = Dump::factory()->createOne(); $changes = Dump::factory()->makeOne(); $dump->fill($changes->getAttributes()); $dump->save(); Event::assertDispatched(DumpUpdated::class); } /** * The DumpUpdated event shall contain embed fields. * * @return void */ public function testDumpUpdatedEventEmbedFields(): void { $dump = Dump::factory()->createOne(); $changes = Dump::factory()->makeOne(); $dump->fill($changes->getAttributes()); $dump->save(); Event::assertDispatched(DumpUpdated::class, function (DumpUpdated $event) { $message = $event->getDiscordMessage(); return ! empty(Arr::get($message->embed, 'fields')); }); } }