mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
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:
parent
84feacd6b2
commit
151bdd04ef
2 changed files with 14 additions and 12 deletions
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue