diff --git a/cake/libs/folder.php b/cake/libs/folder.php index 01b5a6da3..82f3b4e6a 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -110,7 +110,9 @@ class Folder extends Object{ if (!$this->isAbsolute($path)) { $path = realpath($path); } - $this->cd($path); + if (!empty($path)) { + $this->cd($path); + } } /** * Return current path. diff --git a/cake/tests/cases/libs/folder.test.php b/cake/tests/cases/libs/folder.test.php index 41d800672..bd9967da4 100644 --- a/cake/tests/cases/libs/folder.test.php +++ b/cake/tests/cases/libs/folder.test.php @@ -106,17 +106,20 @@ class FolderTest extends UnitTestCase { $result = $Folder->delete($mv); $this->assertTrue($result); - + $new = TMP . 'test_folder_new'; $result = $Folder->create($new); $this->assertTrue($result); - + $result = $Folder->cd($new); $this->assertTrue($result); - + $result = $Folder->delete(); $this->assertTrue($result); - + + $Folder =& new Folder('non-existent'); + $result = $Folder->pwd(); + $this->assertNull($result); } function testRealPathForWebroot() {