mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 23:49:55 +00:00
Updating folder::delete() to properly record file deletions. Thanks for the patch 'davidpersson'. Tests Added. Closes #5394
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7570 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
fe82e827f0
commit
d791603791
2 changed files with 31 additions and 2 deletions
|
@ -544,9 +544,9 @@ class Folder extends Object {
|
||||||
}
|
}
|
||||||
if (is_file($file) === true) {
|
if (is_file($file) === true) {
|
||||||
if (@unlink($file)) {
|
if (@unlink($file)) {
|
||||||
$this->__messages[] = sprintf(__('%s removed', true), $path);
|
$this->__messages[] = sprintf(__('%s removed', true), $file);
|
||||||
} else {
|
} else {
|
||||||
$this->__errors[] = sprintf(__('%s NOT removed', true), $path);
|
$this->__errors[] = sprintf(__('%s NOT removed', true), $file);
|
||||||
}
|
}
|
||||||
} elseif (is_dir($file) === true) {
|
} elseif (is_dir($file) === true) {
|
||||||
if ($this->delete($file) === false) {
|
if ($this->delete($file) === false) {
|
||||||
|
|
|
@ -460,5 +460,34 @@ class FolderTest extends CakeTestCase {
|
||||||
$folder->cd(TMP);
|
$folder->cd(TMP);
|
||||||
$folder->delete($folder->pwd().'config_non_existant');
|
$folder->delete($folder->pwd().'config_non_existant');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testDelete method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testDelete() {
|
||||||
|
$path = TMP . 'folder_delete_test';
|
||||||
|
$Folder =& new Folder($path, true);
|
||||||
|
touch(TMP.'folder_delete_test' . DS . 'file1');
|
||||||
|
touch(TMP.'folder_delete_test' . DS . 'file2');
|
||||||
|
|
||||||
|
$return = $Folder->delete();
|
||||||
|
$this->assertTrue($return);
|
||||||
|
|
||||||
|
$messages = $Folder->messages();
|
||||||
|
$errors = $Folder->errors();
|
||||||
|
$this->assertEqual($errors, array());
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
$path . ' created',
|
||||||
|
$path . DS . 'file1 removed',
|
||||||
|
$path . DS . 'file2 removed',
|
||||||
|
$path . ' removed'
|
||||||
|
);
|
||||||
|
$this->assertEqual($expected, $messages);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue