app->make(CreatesLocations::class); $taken = Location::factory()->create(['short' => 'taken']); expect(fn () => $locations->create(['short' => 'taken']))->toThrow(ValidationException::class) ->and(fn () => $locations->create(['short' => str_repeat('a', 61)]))->toThrow(ValidationException::class); $location = $locations->create(['short' => 'fresh', 'long' => '']); expect($location->long)->toBeNull(); // A location keeps its own short code when it is updated. $this->app->make(UpdatesLocations::class)->update($taken, ['short' => 'taken', 'long' => 'Still here']); expect($taken->refresh()->long)->toBe('Still here'); }); test('extension field values that no request validated are refused', function (): void { expect(fn () => $this->app->make(CreatesLocations::class)->create(['short' => 'ext', 'extensions' => ['billing' => ['plan' => 'pro']]])) ->toThrow(InvalidArgumentException::class, 'must come from a request that validated them'); });