Skip to content

Commit

Permalink
Add tests for #4521 and reformat code.
Browse files Browse the repository at this point in the history
Add a regression test for #4521 as the original author didn't have one.
Reformat a long line since I was nearby already.

Closes #4521
  • Loading branch information
markstory committed Sep 10, 2014
1 parent 29570e1 commit 86bc7f1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
22 changes: 22 additions & 0 deletions lib/Cake/Test/Case/Utility/FolderTest.php
Expand Up @@ -973,6 +973,28 @@ public function testCopyWithSkip() {
$Folder->delete();
}

/**
* Test that SKIP mode skips files too.
*
* @return void
*/
public function testCopyWithSkipFileSkipped() {
$path = TMP . 'folder_test';
$folderOne = $path . DS . 'folder1';
$folderTwo = $path . DS . 'folder2';

new Folder($path, true);
new Folder($folderOne, true);
new Folder($folderTwo, true);
file_put_contents($folderOne . DS . 'fileA.txt', 'Folder One File');
file_put_contents($folderTwo . DS . 'fileA.txt', 'Folder Two File');

$Folder = new Folder($folderOne);
$result = $Folder->copy(array('to' => $folderTwo, 'scheme' => Folder::SKIP));
$this->assertTrue($result);
$this->assertEquals('Folder Two File', file_get_contents($folderTwo . DS . 'fileA.txt'));
}

/**
* testCopyWithOverwrite
*
Expand Down
8 changes: 7 additions & 1 deletion lib/Cake/Utility/Folder.php
Expand Up @@ -645,7 +645,13 @@ public function copy($options) {
$to = $options;
$options = array();
}
$options += array('to' => $to, 'from' => $this->path, 'mode' => $this->mode, 'skip' => array(), 'scheme' => Folder::MERGE);
$options += array(
'to' => $to,
'from' => $this->path,
'mode' => $this->mode,
'skip' => array(),
'scheme' => Folder::MERGE
);

$fromDir = $options['from'];
$toDir = $options['to'];
Expand Down

0 comments on commit 86bc7f1

Please sign in to comment.