Moving the UnitTest directory out of the docs/ folder and into the root of the framework
[isso.git] / UnitTest / RegisterTest.php
1 <?php
2
3 // piggy
4 require_once('ISSO/Register.php');
5
6 /**
7 * Register Test Suite
8 *
9 * @author Blue Static
10 * @copyright Copyright ©2002 - [#]year[#], Blue Static
11 * @version $Revision$
12 * @package ISSO Tests
13 *
14 */
15 class RegisterTest extends UnitTestCase
16 {
17 public function testLoadModule()
18 {
19 $this->assertTrue(BSRegister::LoadModule('Input') instanceof BSInput);
20 }
21
22 public function testLoadBadModule()
23 {
24 BSRegister::LoadModule('nonExistentModule');
25 $this->assertError();
26 }
27
28 public function testSetGetAppPath()
29 {
30 BSRegister::SetAppPath(getcwd());
31 $this->assertEqual(getcwd() . DIRECTORY_SEPARATOR, BSRegister::GetAppPath());
32 }
33
34 public function testSetGetAppVersion()
35 {
36 BSRegister::SetAppVersion('1.0-test');
37 $this->assertEqual('1.0-test', BSRegister::GetAppVersion());
38 }
39
40 public function testSetGetApplication()
41 {
42 BSRegister::SetApplication('ISSO Tests');
43 $this->assertEqual('ISSO Tests', BSRegister::GetApplication());
44 }
45
46 public function testSetGetWebPath()
47 {
48 $path = DIRECTORY_SEPARATOR . 'Server' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR . 'ISSO';
49 BSRegister::SetWebPath($path);
50 $this->assertEqual($path . DIRECTORY_SEPARATOR, BSRegister::GetWebPath());
51 }
52
53 public function testSetGetDebug()
54 {
55 BSRegister::SetDebug(true);
56 $this->assertIdentical(true, BSRegister::GetDebug());
57 }
58
59 public function testDebugList()
60 {
61 $this->assertEqual('<select><option>Debug Notices (0)</option></select>', BSRegister::GetDebugList());
62
63 BSRegister::Debug('dbg');
64 $this->assertEqual('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', BSRegister::GetDebugList());
65 }
66
67 public function testRegisterValue()
68 {
69 BSRegister::Register('someKey', 'someValue');
70
71 $registry = BSRegister::GetAll();
72 $this->assertEqual($registry['someKey'], 'someValue');
73 }
74
75 public function testGetAll()
76 {
77 BSRegister::Register('test', 1);
78 $this->assertIsA(BSRegister::GetAll(), 'array');
79 $this->assertEqual(sizeof(BSRegister::GetAll()), 2);
80 }
81
82 public function testOverWriteRegister()
83 {
84 BSRegister::Register('valueToOverWrite', 1);
85 BSRegister::Register('valueToOverWrite', 2);
86 $this->assertError();
87 $this->assertEqual(1, BSRegister::Get('valueToOverWrite'));
88 }
89
90 public function testGet()
91 {
92 BSRegister::Register('testGet', 123);
93 $this->assertEqual(123, BSRegister::Get('testGet'));
94 }
95
96 public function testUnregister()
97 {
98 BSRegister::Register('testUnregister', 1);
99 BSRegister::Unregister('testUnregister');
100 BSRegister::Register('testUnregister', 2);
101 $this->assertNoErrors();
102 $this->assertEqual(2, BSRegister::Get('testUnregister'));
103 }
104
105 public function testGetNoExist()
106 {
107 BSRegister::Get('doesNotExist');
108 $this->assertError();
109 }
110
111 public function testUnregisterNoExist()
112 {
113 BSRegister::Unregister('keyThatWontExist');
114 $this->assertError();
115 }
116
117 public function testGetType()
118 {
119 $input = BSRegister::LoadModule('Input');
120 BSRegister::Register('input', $input);
121 $this->assertReference($input, BSRegister::GetType('Input'));
122
123 $this->assertEqual(null, BSRegister::GetType('Date'));
124 }
125
126 public function testRequiredModules()
127 {
128 BSRegister::RequiredModules(array('Input'));
129 $this->assertNoErrors();
130
131 BSRegister::RequiredModules(array('Input', 'Db'));
132 $this->assertError();
133
134 BSRegister::RequiredModules(array('Date'));
135 $this->assertError();
136 }
137 }
138
139 ?>