Skip to content

Commit

Permalink
Fix failing tests.
Browse files Browse the repository at this point in the history
You can't use finfo on files that don't exist.
  • Loading branch information
markstory committed Dec 19, 2011
1 parent f959fce commit 2d68e7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Cake/Test/Case/Utility/FileTest.php
Expand Up @@ -73,8 +73,12 @@ public function testBasic() {

$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);

Expand Down
3 changes: 3 additions & 0 deletions lib/Cake/Utility/File.php
Expand Up @@ -554,6 +554,9 @@ public function copy($dest, $overwrite = true) {
* @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()));
Expand Down

0 comments on commit 2d68e7d

Please sign in to comment.