1 file.test FileFileTypeClassificationTestCase::testFileTypeClassification()

Test that existing files are properly classified by file type.

File

core/modules/file/tests/file.test, line 1798
Tests for file.module.

Class

FileFileTypeClassificationTestCase
Tests file type classification functionality.

Code

function testFileTypeClassification() {
  // Get test text and image files.
  $file = current($this->backdropGetTestFiles('text'));
  $text_file = new File((array) $file);
  file_save($text_file);

  $file = current($this->backdropGetTestFiles('image'));
  $image_file = new File((array) $file);
  file_save($image_file);

  // The classification process should assign a file type to any file whose
  // MIME type is assigned to a file type. Check to see if each file was
  // assigned a proper file type.
  $file_type = $this->getFileType($text_file);
  $this->assertEqual($file_type['type'], 'document', t('The text file was properly assigned the Document file type.'));
  $file_type = $this->getFileType($image_file);
  $this->assertEqual($file_type['type'], 'image', t('The image file was properly assigned the Image file type.'));
}