1.20.x file.test FileValidatorTest::testFileValidateExtensions()

Test the file_validate_extensions() function.

File

modules/simpletest/tests/file.test, line 378
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 File(array('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');
}