Permalink
Browse files

Add test case for Folder::tree with hidden files

  • Loading branch information...
1 parent f367249 commit 97fbcd1079a4cd1ebad1d602f77c10063ff9487c @shama shama committed Dec 10, 2011
Showing with 45 additions and 0 deletions.
  1. +45 −0 lib/Cake/Test/Case/Utility/FolderTest.php
View
45 lib/Cake/Test/Case/Utility/FolderTest.php
@@ -412,6 +412,51 @@ public function testFolderTree() {
}
/**
+ * testFolderTreeWithHiddenFiles method
+ *
+ * @return void
+ */
+ public function testFolderTreeWithHiddenFiles() {
+ $this->skipIf(!is_writeable(TMP), 'Cant test Folder::tree with hidden files unless the tmp folder is writable.');
+
+ $Folder = new Folder(TMP . 'folder_tree_hidden', true, 0777);
+ mkdir($Folder->path . DS . '.svn', 0777, true);
+ touch($Folder->path . DS . '.svn' . DS . 'InHiddenFolder.php');
+ touch($Folder->path . DS . 'not_hidden.txt');
+ touch($Folder->path . DS . '.hidden.txt');
+
+ $expected = array(
+ array(
+ $Folder->path,
+ ),
+ array(
+ $Folder->path . DS . 'not_hidden.txt',
+ $Folder->path . DS . '.svn' . DS . 'InHiddenFolder.php',
+ ),
+ );
+
+ $result = $Folder->tree(null, false);
+ $this->assertEquals($expected, $result);
+
+ $expected = array(
+ array(
+ $Folder->path,
+ $Folder->path . DS . '.svn',
+ ),
+ array(
+ $Folder->path . DS . 'not_hidden.txt',
+ $Folder->path . DS . '.hidden.txt',
+ $Folder->path . DS . '.svn' . DS . 'InHiddenFolder.php',
+ ),
+ );
+
+ $result = $Folder->tree(null, true);
+ $this->assertEquals($expected, $result);
@ceeram
ceeram Dec 10, 2011

For some reason Jenkins returns the files in a different order. I tried this locally and it passed just fine.

+
+ $Folder->delete();
+ }
+
+/**
* testWindowsPath method
*
* @return void

0 comments on commit 97fbcd1

Please sign in to comment.