summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/helpers/directory_helper_test.php
blob: 3fae81b829d4c05695094385ea8bf68664cb072f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

require_once 'vfsStream/vfsStream.php';
require BASEPATH.'helpers/directory_helper.php';

class Directory_helper_test extends CI_TestCase
{
	public function set_up()
	{
		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 recursion depth behavior
		$expected = array('libraries');
			
		$this->assertEquals($expected, directory_map(vfsStream::url('testDir'), 1));

		// test detection of hidden files
		$expected = array('libraries' => array('benchmark.html', 'database' =>
			array('active_record.html', 'binds.html'), 'email.html', '.hiddenfile.txt'));
			
		$this->assertEquals($expected, directory_map(vfsStream::url('testDir'), FALSE, TRUE));
  }  
}

/* End of file directory_helper_test.php */