Hamza Bhatti | 575895f | 2012-03-11 11:58:31 +0400 | [diff] [blame] | 1 | <?php |
| 2 | |
Taufan Aditya | e1dc9ea | 2012-03-28 16:49:49 +0700 | [diff] [blame] | 3 | class Directory_helper_test extends CI_TestCase { |
| 4 | |
Hamza Bhatti | 575895f | 2012-03-11 11:58:31 +0400 | [diff] [blame] | 5 | public function set_up() |
| 6 | { |
Taufan Aditya | e1dc9ea | 2012-03-28 16:49:49 +0700 | [diff] [blame] | 7 | $this->helper('directory'); |
| 8 | |
Hamza Bhatti | 575895f | 2012-03-11 11:58:31 +0400 | [diff] [blame] | 9 | vfsStreamWrapper::register(); |
| 10 | vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir')); |
| 11 | |
| 12 | $this->_test_dir = vfsStreamWrapper::getRoot(); |
| 13 | } |
| 14 | |
| 15 | public function test_directory_map() |
| 16 | { |
| 17 | $structure = array('libraries' => array('benchmark.html' => '', 'database' => |
| 18 | array('active_record.html' => '', 'binds.html' => ''), 'email.html' => '', '.hiddenfile.txt' => '')); |
| 19 | |
| 20 | vfsStream::create($structure, $this->_test_dir); |
| 21 | |
| 22 | // test default recursive behavior |
| 23 | $expected = array('libraries' => array('benchmark.html', 'database' => |
| 24 | array('active_record.html', 'binds.html'), 'email.html')); |
| 25 | |
| 26 | $this->assertEquals($expected, directory_map(vfsStream::url('testDir'))); |
| 27 | |
| 28 | // test recursion depth behavior |
| 29 | $expected = array('libraries'); |
| 30 | |
| 31 | $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), 1)); |
| 32 | |
| 33 | // test detection of hidden files |
| 34 | $expected = array('libraries' => array('benchmark.html', 'database' => |
| 35 | array('active_record.html', 'binds.html'), 'email.html', '.hiddenfile.txt')); |
| 36 | |
| 37 | $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), FALSE, TRUE)); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | /* End of file directory_helper_test.php */ |