function FileValidatorTest::testFileValidateExtensions in Drupal 7
Test the file_validate_extensions() function.
File
- modules/
simpletest/ tests/ file.test, line 387 - This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.
Class
- FileValidatorTest
- This will run tests against the file validation functions (file_validate_*).
Code
function testFileValidateExtensions() {
$file = new stdClass();
$file->filename = 'asdf.txt';
$errors = file_validate_extensions($file, 'asdf txt pork');
$this
->assertEqual(count($errors), 0, 'Valid extension accepted.', 'File');
$file->filename = 'asdf.txt';
$errors = file_validate_extensions($file, 'exe png');
$this
->assertEqual(count($errors), 1, 'Invalid extension blocked.', 'File');
}