fixing File tests and class

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5221 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-05-29 23:38:36 +00:00
parent 84feacd6b2
commit 151bdd04ef
2 changed files with 14 additions and 12 deletions

View file

@ -170,7 +170,11 @@ class File extends Object{
* @access public * @access public
*/ */
function info() { function info() {
return pathinfo($this->pwd()); $info = pathinfo($this->pwd());
if(!isset($info['filename'])) {
$info['filename'] = $this->filename();
}
return $info;
} }
/** /**
* Returns the File extension. * Returns the File extension.
@ -192,9 +196,8 @@ class File extends Object{
* @access public * @access public
*/ */
function filename() { function filename() {
$info = $this->info(); if($ext = $this->ext()) {
if(isset($info['filename'])) { return basename($this->name, '.'.$ext);
return $info['filename'];
} }
return false; return false;
} }

View file

@ -52,8 +52,7 @@ class FileTest extends UnitTestCase {
$this->assertEqual($result, $expecting); $this->assertEqual($result, $expecting);
$result = $this->File->info(); $result = $this->File->info();
$expecting = array('dirname'=> dirname(__FILE__), 'basename'=> basename(__FILE__), $expecting = array('dirname'=> dirname(__FILE__), 'basename'=> basename(__FILE__), 'extension'=> 'php', 'filename'=>'file.test');
'extension'=> 'php', 'filename'=> 'file.test');
$this->assertEqual($result, $expecting); $this->assertEqual($result, $expecting);
$result = $this->File->ext(); $result = $this->File->ext();