file_put_contents($this->path, '1'
);
$file =
new UploadedFile($this->path, 'myFileWithATooLongOriginalFileName', null, null, true
);
$this->validator->
validate($file,
$constraintFile);
$this->
buildViolation($messageViolation) ->
setParameters([ '{{ filename_max_length }}' =>
$constraintFile->filenameMaxLength,
]) ->
setCode(File::FILENAME_TOO_LONG
) ->
setPlural($constraintFile->filenameMaxLength
) ->
assertRaised();
} public static function provideFilenameMaxLengthIsTooLong(): \Generator
{ yield 'Simple case with only the parameter "filenameMaxLength" ' =>
[ new File(filenameMaxLength: 30
),
'The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.',
];
yield 'Case with the parameter "filenameMaxLength" and a custom error message' =>
[