blob: 176ff1d789a54a56dee1c519c75e6ae96d4f301a [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 {
Andrey Andreev99b782d2012-06-09 22:24:46 +03004
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'));
Andrey Andreev99b782d2012-06-09 22:24:46 +030011
Hamza Bhatti575895f2012-03-11 11:58:31 +040012 $this->_test_dir = vfsStreamWrapper::getRoot();
Andrey Andreev99b782d2012-06-09 22:24:46 +030013 }
14
Hamza Bhatti575895f2012-03-11 11:58:31 +040015 public function test_directory_map()
16 {
Andrey Andreev99b782d2012-06-09 22:24:46 +030017 $structure = array(
18 'libraries' => array(
19 'benchmark.html' => '',
20 'database' => array('active_record.html' => '', 'binds.html' => ''),
21 'email.html' => '',
22 '.hiddenfile.txt' => ''
23 )
24 );
25
Hamza Bhatti575895f2012-03-11 11:58:31 +040026 vfsStream::create($structure, $this->_test_dir);
27
28 // test default recursive behavior
Andrey Andreev99b782d2012-06-09 22:24:46 +030029 $expected = array(
30 'libraries' => array(
31 'benchmark.html',
32 'database' => array('active_record.html', 'binds.html'),
33 'email.html'
34 )
35 );
36
Hamza Bhatti575895f2012-03-11 11:58:31 +040037 $this->assertEquals($expected, directory_map(vfsStream::url('testDir')));
38
Hamza Bhatti575895f2012-03-11 11:58:31 +040039 // test detection of hidden files
Andrey Andreev99b782d2012-06-09 22:24:46 +030040 $expected['libraries'][] = '.hiddenfile.txt';
41
Hamza Bhatti575895f2012-03-11 11:58:31 +040042 $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), FALSE, TRUE));
Andrey Andreev99b782d2012-06-09 22:24:46 +030043
44 // test recursion depth behavior
45 $this->assertEquals(array('libraries'), directory_map(vfsStream::url('testDir'), 1));
46 }
47
Hamza Bhatti575895f2012-03-11 11:58:31 +040048}
49
50/* End of file directory_helper_test.php */