mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-03 01:52:40 +00:00
Made default value and behavior of param $exceptions
for Folder::tree() identical to same param in Folder::read()
This commit is contained in:
parent
b84c9a1aaa
commit
bcab3d0cb9
3 changed files with 58 additions and 16 deletions
|
@ -363,6 +363,41 @@ class FolderTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testFolderReadWithHiddenFiles method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFolderReadWithHiddenFiles() {
|
||||
$this->skipIf(!is_writeable(TMP), 'Cant test Folder::read with hidden files unless the tmp folder is writable.');
|
||||
|
||||
$Folder = new Folder(TMP . 'folder_tree_hidden', true, 0777);
|
||||
mkdir($Folder->path . DS . '.svn');
|
||||
mkdir($Folder->path . DS . 'some_folder');
|
||||
touch($Folder->path . DS . 'not_hidden.txt');
|
||||
touch($Folder->path . DS . '.hidden.txt');
|
||||
|
||||
$expected = array(
|
||||
array('some_folder'),
|
||||
array('not_hidden.txt'),
|
||||
);
|
||||
$result = $Folder->read(true, true);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$expected = array(
|
||||
array(
|
||||
'.svn',
|
||||
'some_folder'
|
||||
),
|
||||
array(
|
||||
'.hidden.txt',
|
||||
'not_hidden.txt'
|
||||
),
|
||||
);
|
||||
$result = $Folder->read(true);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testFolderTree method
|
||||
*
|
||||
|
@ -417,41 +452,47 @@ class FolderTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testFolderTreeWithHiddenFiles() {
|
||||
$this->skipIf(!is_writeable(TMP), 'Cant test Folder::tree with hidden files unless the tmp folder is writable.');
|
||||
$this->skipIf(!is_writeable(TMP), 'Can\'t 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');
|
||||
mkdir($Folder->path . DS . '.svn' . DS . 'inhiddenfolder');
|
||||
touch($Folder->path . DS . '.svn' . DS . 'inhiddenfolder' . DS . 'NestedInHiddenFolder.php');
|
||||
touch($Folder->path . DS . 'not_hidden.txt');
|
||||
touch($Folder->path . DS . '.hidden.txt');
|
||||
mkdir($Folder->path . DS . 'visible_folder' . DS . '.git', 0777, true);
|
||||
|
||||
$expected = array(
|
||||
array(
|
||||
$Folder->path,
|
||||
$Folder->path . DS . 'visible_folder',
|
||||
),
|
||||
array(
|
||||
$Folder->path . DS . 'not_hidden.txt',
|
||||
),
|
||||
);
|
||||
|
||||
$result = $Folder->tree(null, false);
|
||||
sort($result[1]);
|
||||
sort($expected[1]);
|
||||
$result = $Folder->tree(null, true);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$expected = array(
|
||||
array(
|
||||
$Folder->path,
|
||||
$Folder->path . DS . 'visible_folder',
|
||||
$Folder->path . DS . 'visible_folder' . DS . '.git',
|
||||
$Folder->path . DS . '.svn',
|
||||
$Folder->path . DS . '.svn' . DS . 'inhiddenfolder',
|
||||
),
|
||||
array(
|
||||
$Folder->path . DS . 'not_hidden.txt',
|
||||
$Folder->path . DS . '.hidden.txt',
|
||||
$Folder->path . DS . '.svn' . DS . 'inhiddenfolder' . DS . 'NestedInHiddenFolder.php',
|
||||
$Folder->path . DS . '.svn' . DS . 'InHiddenFolder.php',
|
||||
),
|
||||
);
|
||||
|
||||
$result = $Folder->tree(null, true);
|
||||
$result = $Folder->tree(null, false);
|
||||
sort($result[1]);
|
||||
sort($expected[1]);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue