Fix failing tests.

You can't use finfo on files that don't exist.
This commit is contained in:
mark_story 2011-12-18 23:26:57 -05:00
parent f959fcefc4
commit 2d68e7da1e
2 changed files with 9 additions and 2 deletions

View file

@ -73,8 +73,12 @@ class FileTest extends CakeTestCase {
$result = $this->File->info();
$expecting = array(
'dirname' => dirname(__FILE__), 'basename' => basename(__FILE__),
'extension' => 'php', 'filename' =>'FileTest', 'filesize' => filesize($file)
'dirname' => dirname(__FILE__),
'basename' => basename(__FILE__),
'extension' => 'php',
'filename' =>'FileTest',
'filesize' => filesize($file),
'mime' => 'text/x-php'
);
$this->assertEquals($expecting, $result);

View file

@ -554,6 +554,9 @@ class File {
* @return false|string The mimetype of the file, or false if reading fails.
*/
public function mime() {
if (!$this->exists()) {
return false;
}
if (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
list($type, $charset) = explode(';', finfo_file($finfo, $this->pwd()));