TestFuncCrypt::TestMcryptSmplIv()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Test - crypt func
4
 * @package     fwolflib
5
 * @subpackage	func-test
6
 * @copyright   Copyright 2009, Fwolf
7
 * @author      Fwolf <[email protected]>
8
 * @since		2009-10-22
9
 * @version		$Id$
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
// Require library define file which need test
23
require_once('fwlib/func/crypt.php');
24
require_once('fwlib/func/request.php');
25
26
class TestFuncCrypt extends UnitTestCase {
27
28
    function TestMcryptSmplIv() {
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...
29
		$s_key = 'blahblahblah';
30
		$s_data = '加密的东东';
31
		$s_algo = 'xtea';
32
33
		$s_data_encrypted = McryptSmplIvEncrypt($s_data, $s_key, $s_algo);
0 ignored issues
show
Deprecated Code introduced by
The function McryptSmplIvEncrypt() has been deprecated with message: Use Fwlib\Util\McryptSmplIv::encrypt()

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...
34
		$this->assertEqual(base64_encode($s_data_encrypted),
35
			'8vAJEMIdSmH3udoxZ3va');
36
37
		$s_data_decrypted = McryptSmplIvDecrypt($s_data_encrypted, $s_key, $s_algo);
0 ignored issues
show
Deprecated Code introduced by
The function McryptSmplIvDecrypt() has been deprecated with message: Use Fwlib\Util\McryptSmplIv::decrypt()

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
		$this->assertEqual($s_data_decrypted, $s_data);
39
    } // end of func TestMcryptSmplIv
40
41
} // end of class TestFuncCrypt
42
43
44
// Change output charset in this way.
45
// {{{
46
$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...
47
$s_url = substr($s_url, strrpos($s_url, '/') + 1);
48
if ('crypt.test.php' == $s_url) {
49
	$test = new TestFuncCrypt();
50
	$test->run(new HtmlReporter('utf-8'));
51
}
52
// }}}
53
?>
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...
54