From 86bc7f186194bb1da3b84873987fb4be0071b85f Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 9 Sep 2014 21:33:14 -0400 Subject: [PATCH] Add tests for #4521 and reformat code. 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 --- lib/Cake/Test/Case/Utility/FolderTest.php | 22 ++++++++++++++++++++++ lib/Cake/Utility/Folder.php | 8 +++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index c1f0e6cb8..fe1728da5 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -973,6 +973,28 @@ class FolderTest extends CakeTestCase { $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 * diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index 7d768dff4..43337d4a4 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -645,7 +645,13 @@ class Folder { $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'];