From cbd22269f81552616377090f6fe9187fdeb656d9 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 2 Jun 2009 13:42:40 +0000 Subject: - Patch #473652 by Damien Tournoud, catch: removed unneeded loop from file_get_mimetype() and further clean-up. --- modules/simpletest/tests/file.test | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'modules/simpletest') diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test index b5c1aa1ec..bbf434055 100644 --- a/modules/simpletest/tests/file.test +++ b/modules/simpletest/tests/file.test @@ -1997,3 +1997,37 @@ class FileNameMungingTest extends FileTestCase { // $this->assertIdentical($unmunged_name, $this->name, t('The unmunged (%unmunged) filename matches the original (%original)', array('%unmunged' => $unmunged_name, '%original' => $this->name))); } } + +/** + * Tests for file_get_mimetype(). + */ +class FileMimeTypeTest extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => t('File mimetypes'), + 'description' => t('Test filename mimetype detection.'), + 'group' => t('File'), + ); + } + + /** + * Test basic extraction of mimetypes from the filename. + */ + public function testFileMimeTypeDetection() { + $test_case = array( + 'test.jar' => 'application/java-archive', + 'test.jpeg' => 'image/jpeg', + 'test.jpg' => 'image/jpeg', + 'test.jar.jpg' => 'image/jpeg', + 'test.jpg.jar' => 'application/java-archive', + 'test.pcf.Z' => 'application/x-font', + 'pcf.Z' => 'application/octet-stream', + 'jar' => 'application/octet-stream', + ); + + foreach ($test_case as $input => $expected) { + $output = file_get_mimetype($input); + $this->assertIdentical($output, $expected, t('Mimetype for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected))); + } + } +} -- cgit v1.2.3