blob: 3937d29132afa297a7da4a22fdac95b155766a4c [file] [log] [blame]
Hamza Bhatti575895f2012-03-11 11:58:31 +04001<?php
2
Taufan Adityae1dc9ea2012-03-28 16:49:49 +07003class Directory_helper_test extends CI_TestCase {
4
Hamza Bhatti575895f2012-03-11 11:58:31 +04005 public function set_up()
6 {
Taufan Adityae1dc9ea2012-03-28 16:49:49 +07007 $this->helper('directory');
8
Hamza Bhatti575895f2012-03-11 11:58:31 +04009 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 */