summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-06-02 13:42:40 +0000
committerDries Buytaert <dries@buytaert.net>2009-06-02 13:42:40 +0000
commitcbd22269f81552616377090f6fe9187fdeb656d9 (patch)
treecc608c17da23f815909195762322cef3960b8ddd /modules/simpletest
parentb8f18b39c29b5297d76037ba8ac69941baaaab86 (diff)
downloadbrdo-cbd22269f81552616377090f6fe9187fdeb656d9.tar.gz
brdo-cbd22269f81552616377090f6fe9187fdeb656d9.tar.bz2
- Patch #473652 by Damien Tournoud, catch: removed unneeded loop from file_get_mimetype() and further clean-up.
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/file.test34
1 files changed, 34 insertions, 0 deletions
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)));
+ }
+ }
+}