use(WithFaker::class); test('passes if enum description', function (): void { $enum = Arr::random(LocalizedEnum::cases()); $attribute = fake()->word(); $validator = Validator::make( [$attribute => $enum->localize()], [$attribute => new EnumLocalizedNameRule(LocalizedEnum::class)] ); expect($validator->passes())->toBeTrue(); }); test('fails if enum value', function (): void { $enum = Arr::random(LocalizedEnum::cases()); $attribute = fake()->word(); $validator = Validator::make( [$attribute => $enum->value], [$attribute => new EnumLocalizedNameRule(LocalizedEnum::class)] ); expect($validator->passes())->toBeFalse(); }); test('fails if string', function (): void { $attribute = fake()->word(); $validator = Validator::make( [$attribute => Str::random()], [$attribute => new EnumLocalizedNameRule(LocalizedEnum::class)] ); expect($validator->passes())->toBeFalse(); });