diff --git a/cake/libs/file.php b/cake/libs/file.php index 274371a3d..2ecc5fb37 100644 --- a/cake/libs/file.php +++ b/cake/libs/file.php @@ -170,8 +170,12 @@ class File extends Object{ * @access public */ function info() { - return pathinfo($this->pwd()); - } + $info = pathinfo($this->pwd()); + if(!isset($info['filename'])) { + $info['filename'] = $this->filename(); + } + return $info; + } /** * Returns the File extension. * @@ -192,12 +196,11 @@ class File extends Object{ * @access public */ function filename() { - $info = $this->info(); - if(isset($info['filename'])) { - return $info['filename']; + if($ext = $this->ext()) { + return basename($this->name, '.'.$ext); } return false; - } + } /** * Returns the File's owner. * diff --git a/cake/tests/cases/libs/file.test.php b/cake/tests/cases/libs/file.test.php index 6d4c05e14..a64b7a19e 100644 --- a/cake/tests/cases/libs/file.test.php +++ b/cake/tests/cases/libs/file.test.php @@ -50,16 +50,15 @@ class FileTest extends UnitTestCase { $result = $this->File->name; $expecting = basename(__FILE__); $this->assertEqual($result, $expecting); - + $result = $this->File->info(); - $expecting = array('dirname'=> dirname(__FILE__), 'basename'=> basename(__FILE__), - 'extension'=> 'php', 'filename'=> 'file.test'); + $expecting = array('dirname'=> dirname(__FILE__), 'basename'=> basename(__FILE__), 'extension'=> 'php', 'filename'=>'file.test'); $this->assertEqual($result, $expecting); - + $result = $this->File->ext(); $expecting = 'php'; $this->assertEqual($result, $expecting); - + $result = $this->File->filename(); $expecting = 'file.test'; $this->assertEqual($result, $expecting); @@ -83,7 +82,7 @@ class FileTest extends UnitTestCase { $result = $this->File->perms(); $expecting = '0644'; $this->assertEqual($result, $expecting); - + $result = $this->File->Folder(); $this->assertIsA($result, 'Folder');