diff options
Diffstat (limited to 'tests/codeigniter/helpers/directory_helper_test.php')
-rw-r--r-- | tests/codeigniter/helpers/directory_helper_test.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php new file mode 100644 index 000000000..176ff1d78 --- /dev/null +++ b/tests/codeigniter/helpers/directory_helper_test.php @@ -0,0 +1,50 @@ +<?php + +class Directory_helper_test extends CI_TestCase { + + public function set_up() + { + $this->helper('directory'); + + vfsStreamWrapper::register(); + vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir')); + + $this->_test_dir = vfsStreamWrapper::getRoot(); + } + + public function test_directory_map() + { + $structure = array( + 'libraries' => array( + 'benchmark.html' => '', + 'database' => array('active_record.html' => '', 'binds.html' => ''), + 'email.html' => '', + '.hiddenfile.txt' => '' + ) + ); + + vfsStream::create($structure, $this->_test_dir); + + // test default recursive behavior + $expected = array( + 'libraries' => array( + 'benchmark.html', + 'database' => array('active_record.html', 'binds.html'), + 'email.html' + ) + ); + + $this->assertEquals($expected, directory_map(vfsStream::url('testDir'))); + + // test detection of hidden files + $expected['libraries'][] = '.hiddenfile.txt'; + + $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), FALSE, TRUE)); + + // test recursion depth behavior + $this->assertEquals(array('libraries'), directory_map(vfsStream::url('testDir'), 1)); + } + +} + +/* End of file directory_helper_test.php */
\ No newline at end of file |