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,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.
*

View file

@ -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');