public function ValidatorTest::providerTestFileValidateExtensionsOnUri in Drupal 9
Same name and namespace in other branches
- 10 core/modules/file/tests/src/Kernel/ValidatorTest.php \Drupal\Tests\file\Kernel\ValidatorTest::providerTestFileValidateExtensionsOnUri()
Data provider for ::testFileValidateExtensionsOnUri.
Return value
array[][] The test cases.
File
- core/
modules/ file/ tests/ src/ Kernel/ ValidatorTest.php, line 82
Class
- ValidatorTest
- Tests the functions used to validate uploaded files.
Namespace
Drupal\Tests\file\KernelCode
public 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,
'Allowed_extensions' => [
'asdf',
'txt',
'pork',
],
'Expected errors' => [],
],
'Temporary txt validated with "exe" and "png"' => [
'File properties' => $temporary_txt_file_properties,
'Allowed_extensions' => [
'exe',
'png',
],
'Expected errors' => [
'Only files with the following extensions are allowed: <em class="placeholder">exe png</em>.',
],
],
'Permanent txt validated with "asdf", "txt", "pork"' => [
'File properties' => $permanent_txt_file_properties,
'Allowed_extensions' => [
'asdf',
'txt',
'pork',
],
'Expected errors' => [],
],
'Permanent txt validated with "exe" and "png"' => [
'File properties' => $permanent_txt_file_properties,
'Allowed_extensions' => [
'exe',
'png',
],
'Expected errors' => [
'Only files with the following extensions are allowed: <em class="placeholder">exe png</em>.',
],
],
'Permanent png validated with "png", "gif", "jpg", "jpeg"' => [
'File properties' => $permanent_png_file_properties,
'Allowed_extensions' => [
'png',
'gif',
'jpg',
'jpeg',
],
'Expected errors' => [],
],
'Permanent png validated with "exe" and "txt"' => [
'File properties' => $permanent_png_file_properties,
'Allowed_extensions' => [
'exe',
'txt',
],
'Expected errors' => [
'Only files with the following extensions are allowed: <em class="placeholder">exe txt</em>.',
],
],
];
}