function FileExtensionConstraintValidatorTest::providerTestFileValidateExtensionsOnUri
Same name in other branches
- 11.x core/modules/file/tests/src/Kernel/Plugin/Validation/Constraint/FileExtensionConstraintValidatorTest.php \Drupal\Tests\file\Kernel\Plugin\Validation\Constraint\FileExtensionConstraintValidatorTest::providerTestFileValidateExtensionsOnUri()
Data provider for ::testFileExtensionOnUri.
Return value
array[][] The test cases.
File
-
core/
modules/ file/ tests/ src/ Kernel/ Plugin/ Validation/ Constraint/ FileExtensionConstraintValidatorTest.php, line 53
Class
- FileExtensionConstraintValidatorTest
- Tests the FileExtensionConstraintValidator.
Namespace
Drupal\Tests\file\Kernel\Plugin\Validation\ConstraintCode
public static function providerTestFileValidateExtensionsOnUri() : array {
$temporary_txt_file_properties = [
'filename' => 'asdf.txt',
'uri' => 'temporary://asdf',
'status' => 0,
];
$permanent_txt_file_properties = [
'filename' => 'asdf.txt',
'uri' => 'public://asdf_0.txt',
'status' => 1,
];
$permanent_png_file_properties = [
'filename' => 'The Druplicon',
'uri' => 'public://druplicon.png',
'status' => 1,
];
return [
'Temporary txt validated with "asdf", "txt", "pork"' => [
'file_properties' => $temporary_txt_file_properties,
'extensions' => [
'asdf',
'txt',
'pork',
],
'expected_errors' => [],
],
'Temporary txt validated with "exe" and "png"' => [
'file_properties' => $temporary_txt_file_properties,
'extensions' => [
'exe',
'png',
],
'expected_errors' => [
'Only files with the following extensions are allowed: exe png.',
],
],
'Permanent txt validated with "asdf", "txt", "pork"' => [
'file_properties' => $permanent_txt_file_properties,
'extensions' => [
'asdf',
'txt',
'pork',
],
'expected_errors' => [],
],
'Permanent txt validated with "exe" and "png"' => [
'file_properties' => $permanent_txt_file_properties,
'extensions' => [
'exe',
'png',
],
'expected_errors' => [
'Only files with the following extensions are allowed: exe png.',
],
],
'Permanent png validated with "png", "gif", "jpg", "jpeg"' => [
'file_properties' => $permanent_png_file_properties,
'extensions' => [
'png',
'gif',
'jpg',
'jpeg',
],
'expected_errors' => [],
],
'Permanent png validated with "exe" and "txt"' => [
'file_properties' => $permanent_png_file_properties,
'extensions' => [
'exe',
'txt',
],
'expected_errors' => [
'Only files with the following extensions are allowed: exe txt.',
],
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.