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