TestFuncFilesystem::TestGetFilenameToWrite()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
1
<?php
2
/**
3
 * Test - filesystem function
4
 *
5
 * @package     fwolflib
6
 * @subpackage	func.test
7
 * @copyright   Copyright 2010, Fwolf
8
 * @author      Fwolf <[email protected]>
9
 * @since		2010-10-10
10
 */
11
12
// Define like this, so test can run both under eclipse and web alone.
13
// {{{
14
if (! defined('SIMPLE_TEST')) {
15
	define('SIMPLE_TEST', 'simpletest/');
16
	require_once(SIMPLE_TEST . 'autorun.php');
17
}
18
// Then set output encoding
19
//header('Content-Type: text/html; charset=utf-8');
20
// }}}
21
22
23
// Require library define file which need test
24
require_once(dirname(__FILE__) . '/../fwolflib.php');
25
require_once(FWOLFLIB . 'func/filesystem.php');
26
require_once(FWOLFLIB . 'func/request.php');
27
require_once(FWOLFLIB . 'func/uuid.php');
28
29
30
class TestFuncFilesystem extends UnitTestCase {
31
32
    function TestGetFilenameToWrite () {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
		// Prepare a filename
34
		$s_name = sys_get_temp_dir();
35
		if ('/' != substr($s_name, -1))
36
			$s_name .= '/';
37
		$s_name .= Uuid();
0 ignored issues
show
Deprecated Code introduced by
The function Uuid() has been deprecated with message: Use Fwlib\Util\Uuid::gen()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
38
		$s_ext = 'ext';
39
		$s_file = $s_name . '.' . $s_ext;
40
41
		// Call 0
42
		$s = GetFilenameToWrite($s_file);
0 ignored issues
show
Deprecated Code introduced by
The function GetFilenameToWrite() has been deprecated with message: Use Fwlib\Util\FileSystem::getNewFile()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
43
    	$this->assertEqual($s, $s_name . '.' . $s_ext);
44
		touch($s);
45
46
		// Call 1
47
		$s = GetFilenameToWrite($s_file);
0 ignored issues
show
Deprecated Code introduced by
The function GetFilenameToWrite() has been deprecated with message: Use Fwlib\Util\FileSystem::getNewFile()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
48
    	$this->assertEqual($s, $s_name . '-1.' . $s_ext);
49
		mkdir($s);
50
51
		// Call 2
52
		$s = GetFilenameToWrite($s_file);
0 ignored issues
show
Deprecated Code introduced by
The function GetFilenameToWrite() has been deprecated with message: Use Fwlib\Util\FileSystem::getNewFile()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
53
    	$this->assertEqual($s, $s_name . '-2.' . $s_ext);
54
		//touch($s);
55
56
    } // end of func GetFilenameToWrite
57
58
59
} // end of class TestFuncFilesystem
60
61
62
// Change output charset in this way.
63
// {{{
64
$s_url = GetSelfUrl(false);
0 ignored issues
show
Deprecated Code introduced by
The function GetSelfUrl() has been deprecated with message: Use Fwlib\Util\HttpUtil::getSelfUrl()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
65
$s_url = substr($s_url, strrpos($s_url, '/') + 1);
66
if (__FILE__ == $s_url) {
67
	$test = new TestFuncFilesystem();
68
	$test->run(new HtmlReporter('utf-8'));
69
}
70
// }}}
71
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
72