2 require_once("__init__.php");
3 require_once('include/platal/env.inc.php');
5 class TestOfEnv
extends UnitTestCase
{
7 $this->UnitTestCase('Env access');
11 $_REQUEST['foo'] = 'baz';
12 $this->assertIdentical(Env
::get('foo'), 'baz');
14 $_REQUEST['foo'] = 123;
15 $this->assertIdentical(Env
::get('foo'), '123');
17 $_REQUEST['foo'] = '123';
18 $this->assertIdentical(Env
::get('foo'), '123');
20 $this->assertIdentical(Env
::get('bar'), '');
21 $this->assertIdentical(Env
::get('bar', 'bar'), 'bar');
24 function test_getMixed() {
25 $_REQUEST['foo'] = 'baz';
26 $this->assertIdentical(Env
::getMixed('foo'), 'baz');
28 $_REQUEST['foo'] = 123;
29 $this->assertIdentical(Env
::getMixed('foo'), 123);
31 $_REQUEST['foo'] = Array(1,'a');
32 $this->assertIdentical(Env
::getMixed('foo'), Array(1,'a'));
34 $this->assertIdentical(Env
::getMixed('bar'), null
);
35 $this->assertIdentical(Env
::getMixed('bar', 'bar'), 'bar');
38 function test_getBool() {
39 $_REQUEST['foo'] = 'baz';
40 $this->assertIdentical(Env
::getBool('foo'), true
);
42 $_REQUEST['foo'] = 123;
43 $this->assertIdentical(Env
::getBool('foo'), true
);
45 $_REQUEST['foo'] = '123';
46 $this->assertIdentical(Env
::getBool('foo'), true
);
48 $this->assertIdentical(Env
::getBool('bar'), false
);
49 $this->assertIdentical(Env
::getBool('bar', true
), true
);
52 function test_getInt() {
53 $_REQUEST['foo'] = 'baz';
54 $this->assertIdentical(Env
::getInt('foo'), 0);
55 $this->assertIdentical(Env
::getInt('foo', 10), 10);
57 $_REQUEST['foo'] = 123;
58 $this->assertIdentical(Env
::getInt('foo'), 123);
60 $_REQUEST['foo'] = '123';
61 $this->assertIdentical(Env
::getInt('foo'), 123);
63 $this->assertIdentical(Env
::getInt('bar'), 0);
64 $this->assertIdentical(Env
::getInt('bar', 123), 123);
67 function test_kill() {
68 $_REQUEST['foo'] = 'baz';
70 $this->assertFalse(isset($_REQUEST['foo']));
73 function test_other_class() {
74 $_POST['foo'] = 'baz';
76 $this->assertFalse(isset($_POST['foo']));
80 $this->assertFalse(isset($_GET['foo']));
84 $test = &new TestOfEnv();
85 $test->run($reporter);