diff --git a/cake/libs/folder.php b/cake/libs/folder.php index 05dd150b2..6b71be4e3 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -473,7 +473,7 @@ class Folder extends Object { } } } - return true; + return false; } /** * Returns the size in bytes of this Folder. diff --git a/cake/tests/cases/libs/folder.test.php b/cake/tests/cases/libs/folder.test.php index ecdf13e99..a95555e54 100644 --- a/cake/tests/cases/libs/folder.test.php +++ b/cake/tests/cases/libs/folder.test.php @@ -82,6 +82,48 @@ class FolderTest extends CakeTestCase { $result = $Folder->inPath(DS . 'non-existing' . $inside); $this->assertFalse($result); } + +/** + * test creation of single and mulitple paths. + * + * @return void + */ + function testCreation() { + $folder =& new Folder(TMP . 'tests'); + $result = $folder->create(TMP . 'tests' . DS . 'first' . DS . 'second' . DS . 'third'); + $this->assertTrue($result); + + rmdir(TMP . 'tests' . DS . 'first' . DS . 'second' . DS . 'third'); + rmdir(TMP . 'tests' . DS . 'first' . DS . 'second'); + rmdir(TMP . 'tests' . DS . 'first'); + + $folder =& new Folder(TMP . 'tests'); + $result = $folder->create(TMP . 'tests' . DS . 'first'); + $this->assertTrue($result); + rmdir(TMP . 'tests' . DS . 'first'); + } +/** + * test recurisve directory create failure. + * + * @return void + */ + function testRecursiveCreateFailure() { + if ($this->skipIf(DS == '\\', 'Cant perform operations using permissions on windows. %s')) { + return; + } + $path = TMP . 'tests' . DS . 'one'; + mkdir($path); + chmod($path, '0444'); + + $this->expectError(); + + $folder =& new Folder($path); + $result = $folder->create($path . DS . 'two' . DS . 'three'); + $this->assertFalse($result); + + chmod($path, '0777'); + rmdir($path); + } /** * testOperations method *