Browse Source

fixed phpcs error, added test for move()

Daniel Lang 11 years ago
parent
commit
8bc4e71fe4
2 changed files with 14 additions and 1 deletions
  1. 1 1
      src/Filesystem/Folder.php
  2. 13 0
      tests/TestCase/Filesystem/FolderTest.php

+ 1 - 1
src/Filesystem/Folder.php

@@ -725,7 +725,7 @@ class Folder
                         $this->delete($to);
                     }
 
-                    if(is_dir($from) && $options['recursive'] === false) {
+                    if (is_dir($from) && $options['recursive'] === false) {
                         continue;
                     }
 

+ 13 - 0
tests/TestCase/Filesystem/FolderTest.php

@@ -1045,6 +1045,7 @@ class FolderTest extends TestCase
         $result = $Folder->copy(['to' => $folderThree, 'recursive' => false]);
 
         $this->assertTrue(file_exists($folderThree . DS . 'file1.php'));
+        $this->assertFalse(is_dir($folderThree . DS . 'folderA'));
         $this->assertFalse(file_exists($folderThree . DS . 'folderA' . DS . 'fileA.php'));
     }
 
@@ -1234,4 +1235,16 @@ class FolderTest extends TestCase
         $Folder = new Folder($path);
         $Folder->delete();
     }
+    
+    public function testMoveWithoutRecursive()
+    {
+        extract($this->_setupFilesystem());
+
+        $Folder = new Folder($folderOne);
+        $result = $Folder->move(['to' => $folderTwo, 'recursive' => false]);
+        $this->assertTrue($result);
+        $this->assertTrue(file_exists($folderTwo . '/file1.php'));
+        $this->assertFalse(is_dir($folderTwo . '/folderA'));
+        $this->assertFalse(file_exists($folderTwo . '/folderA/fileA.php'));
+    }
 }