1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Test - Return value class |
4
|
|
|
* |
5
|
|
|
* @package fwolflib |
6
|
|
|
* @subpackage class.test |
7
|
|
|
* @copyright Copyright 2013, Fwolf |
8
|
|
|
* @author Fwolf <[email protected]> |
9
|
|
|
* @since 2013-05-03 |
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(dirname(__FILE__) . '/../fwolflib.php'); |
24
|
|
|
require_once(FWOLFLIB . 'class/rv/rv.php'); |
25
|
|
|
require_once(FWOLFLIB . 'func/ecl.php'); |
26
|
|
|
require_once(FWOLFLIB . 'func/request.php'); |
27
|
|
|
require_once(FWOLFLIB . 'func/string.php'); |
28
|
|
|
|
29
|
|
|
class TestRv extends UnitTestCase { |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Constructor |
33
|
|
|
*/ |
34
|
|
|
public function __construct () { |
35
|
|
|
|
36
|
|
|
} // end of func __construct |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
public function TestRvDefault () { |
40
|
|
|
$rv = new Rv(); |
|
|
|
|
41
|
|
|
|
42
|
|
|
$this->assertEqual(0, $rv->Code()); |
43
|
|
|
$this->assertEqual('hi', $rv->Msg('hi')); |
44
|
|
|
$this->assertEqual('hi', $rv->Msg(null)); |
45
|
|
|
$this->assertEqual(null, $rv->Msg(null, true)); |
46
|
|
|
|
47
|
|
|
$rv->Code(3); |
48
|
|
|
$this->assertEqual(false, $rv->Error()); |
49
|
|
|
$rv->Code(-3); |
50
|
|
|
$this->assertEqual(true, $rv->Error()); |
51
|
|
|
|
52
|
|
|
} // end of func TestRvDefault |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
} // end of class TestRv |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
// Change output charset in this way. |
59
|
|
|
// {{{ |
60
|
|
|
$s_url = GetSelfUrl(false); |
|
|
|
|
61
|
|
|
$s_url = substr($s_url, strrpos($s_url, '/') + 1); |
62
|
|
|
if ('rv.test.php' == $s_url) { |
63
|
|
|
$test = new TestRv(); |
64
|
|
|
$test->run(new HtmlReporter('utf-8')); |
65
|
|
|
} |
66
|
|
|
// }}} |
67
|
|
|
?> |
|
|
|
|
68
|
|
|
|
This class, trait or interface 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 type will be removed from the class and what other constant to use instead.