Making the entire BSRegister class static
[isso.git] / UnitTest / RegisterTest.php
1 <?php
2
3 // piggy
4 require_once('./../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 testRegisterValue()
60 {
61 BSRegister::Register('someKey', 'someValue');
62
63 $registry = BSRegister::GetAll();
64 $this->assertEqual($registry['someKey'], 'someValue');
65 }
66
67 public function testGetAll()
68 {
69 BSRegister::Register('test', 1);
70 $this->assertIsA(BSRegister::GetAll(), 'array');
71 $this->assertEqual(sizeof(BSRegister::GetAll()), 2);
72 }
73
74 public function testOverWriteRegister()
75 {
76 BSRegister::Register('valueToOverWrite', 1);
77 BSRegister::Register('valueToOverWrite', 2);
78 $this->assertError();
79 $this->assertEqual(1, BSRegister::Get('valueToOverWrite'));
80 }
81
82 public function testGet()
83 {
84 BSRegister::Register('testGet', 123);
85 $this->assertEqual(123, BSRegister::Get('testGet'));
86 }
87
88 public function testUnregister()
89 {
90 BSRegister::Register('testUnregister', 1);
91 BSRegister::Unregister('testUnregister');
92 BSRegister::Register('testUnregister', 2);
93 $this->assertNoErrors();
94 $this->assertEqual(2, BSRegister::Get('testUnregister'));
95 }
96
97 public function testGetNoExist()
98 {
99 BSRegister::Get('doesNotExist');
100 $this->assertError();
101 }
102
103 public function testUnregisterNoExist()
104 {
105 BSRegister::Unregister('keyThatWontExist');
106 $this->assertError();
107 }
108 }
109
110 ?>