Index: library/Zend/File/Transfer/Adapter/Abstract.php =================================================================== --- library/Zend/File/Transfer/Adapter/Abstract.php (revision 19980) +++ library/Zend/File/Transfer/Adapter/Abstract.php (working copy) @@ -1250,8 +1250,6 @@ if (empty($result[$key])) { if (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) { $result[$key] = mime_content_type($file); - } else { - $result[$key] = $value['type']; } } @@ -1511,4 +1509,5 @@ return false; } + } Index: tests/Zend/File/Transfer/Adapter/_files/test.unknown =================================================================== Index: tests/Zend/File/Transfer/Adapter/AbstractTest.php =================================================================== --- tests/Zend/File/Transfer/Adapter/AbstractTest.php (revision 19980) +++ tests/Zend/File/Transfer/Adapter/AbstractTest.php (working copy) @@ -760,6 +760,16 @@ public function testMimeTypeByTmpName() { + // this should throw an exception when the lookup functions are not present + if (!function_exists('mime_content_type') && !class_exists('finfo', false)) { + try { + $this->adapter->getMimeType('baz.text'); + $this->fail('Exception was expected when lookup functions are not present.'); + } catch (Exception $e) { + $this->assertContains('could not been detected', $e->getMessage()); + } + return; + } $this->assertEquals('text/plain', $this->adapter->getMimeType('baz.text')); } @@ -802,6 +812,16 @@ 'bar' => array('magicFile' => 'test/file', 'ignoreNoFile' => false, 'useByteString' => true), ), $this->adapter->getOptions('bar')); } + + /** + * @group ZF-8733 + * @expectedException Zend_File_Transfer_Exception + */ + public function testMimeTypeThrowsExceptionWhenItDetectType() + { + $this->adapter->setValidFileUnknownExtension(); + $this->adapter->getMimeType(); + } } class Zend_File_Transfer_Adapter_AbstractTest_MockAdapter extends Zend_File_Transfer_Adapter_Abstract @@ -932,6 +952,17 @@ ) ); } + + public function setValidFileUnknownExtension() + { + $this->_files = array( + 'test' => array( + 'name' => 'test.unknown', + 'type' => 'image/jpeg', + 'tmp_name' => dirname(__FILE__) . '/_files/test.unknown' + ) + ); + } } // Call Zend_File_Transfer_Adapter_AbstractTest::main() if this source file is executed directly.