From 97fbcd1079a4cd1ebad1d602f77c10063ff9487c Mon Sep 17 00:00:00 2001 From: Kyle Robinson Young Date: Fri, 9 Dec 2011 21:44:15 -0800 Subject: [PATCH] Add test case for Folder::tree with hidden files --- lib/Cake/Test/Case/Utility/FolderTest.php | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 911d27900..06acf119e 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -411,6 +411,51 @@ class FolderTest extends CakeTestCase { $this->assertSame(array_diff($expected[1], $result), array()); } +/** + * 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); + + $Folder->delete(); + } + /** * testWindowsPath method *