mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix failing tests.
You can't use finfo on files that don't exist.
This commit is contained in:
parent
f959fcefc4
commit
2d68e7da1e
2 changed files with 9 additions and 2 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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()));
|
||||
|
|
Loading…
Reference in a new issue