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