mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-12 20:49:50 +00:00
Fixing recursive directory creation when nested create() calls fail. Fixes #347
This commit is contained in:
parent
f4c670e5be
commit
763aa524b9
2 changed files with 43 additions and 1 deletions
|
@ -473,7 +473,7 @@ class Folder extends Object {
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Returns the size in bytes of this Folder.
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue