]>
src.bluestatic.org Git - isso.git/blob - UnitTest/RegisterTest.php
4 require_once('ISSO/Register.php');
10 * @copyright Copyright ©2002 - [#]year[#], Blue Static
15 class RegisterTest
extends UnitTestCase
17 public function testLoadModule()
19 $this->assertTrue(BSRegister
::LoadModule('Input') instanceof BSInput
);
22 public function testLoadBadModule()
24 BSRegister
::LoadModule('nonExistentModule');
28 public function testSetGetAppPath()
30 BSRegister
::SetAppPath(getcwd());
31 $this->assertEqual(getcwd() . DIRECTORY_SEPARATOR
, BSRegister
::GetAppPath());
34 public function testSetGetAppVersion()
36 BSRegister
::SetAppVersion('1.0-test');
37 $this->assertEqual('1.0-test', BSRegister
::GetAppVersion());
40 public function testSetGetApplication()
42 BSRegister
::SetApplication('ISSO Tests');
43 $this->assertEqual('ISSO Tests', BSRegister
::GetApplication());
46 public function testSetGetWebPath()
48 $path = DIRECTORY_SEPARATOR
. 'Server' . DIRECTORY_SEPARATOR
. 'htdocs' . DIRECTORY_SEPARATOR
. 'ISSO';
49 BSRegister
::SetWebPath($path);
50 $this->assertEqual($path . DIRECTORY_SEPARATOR
, BSRegister
::GetWebPath());
53 public function testSetGetDebug()
55 BSRegister
::SetDebug(true);
56 $this->assertIdentical(true, BSRegister
::GetDebug());
59 public function testDebugList()
61 $this->assertEqual('<select><option>Debug Notices (0)</option></select>', BSRegister
::GetDebugList());
63 BSRegister
::Debug('dbg');
64 $this->assertEqual('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', BSRegister
::GetDebugList());
67 public function testRegisterValue()
69 BSRegister
::Register('someKey', 'someValue');
71 $registry = BSRegister
::GetAll();
72 $this->assertEqual($registry['someKey'], 'someValue');
75 public function testGetAll()
77 BSRegister
::Register('test', 1);
78 $this->assertIsA(BSRegister
::GetAll(), 'array');
79 $this->assertEqual(sizeof(BSRegister
::GetAll()), 2);
82 public function testOverWriteRegister()
84 BSRegister
::Register('valueToOverWrite', 1);
85 BSRegister
::Register('valueToOverWrite', 2);
87 $this->assertEqual(1, BSRegister
::Get('valueToOverWrite'));
90 public function testGet()
92 BSRegister
::Register('testGet', 123);
93 $this->assertEqual(123, BSRegister
::Get('testGet'));
96 public function testUnregister()
98 BSRegister
::Register('testUnregister', 1);
99 BSRegister
::Unregister('testUnregister');
100 BSRegister
::Register('testUnregister', 2);
101 $this->assertNoErrors();
102 $this->assertEqual(2, BSRegister
::Get('testUnregister'));
105 public function testGetNoExist()
107 BSRegister
::Get('doesNotExist');
108 $this->assertError();
111 public function testUnregisterNoExist()
113 BSRegister
::Unregister('keyThatWontExist');
114 $this->assertError();
117 public function testGetType()
119 $input = BSRegister
::LoadModule('Input');
120 BSRegister
::Register('input', $input);
121 $this->assertReference($input, BSRegister
::GetType('Input'));
123 $this->assertEqual(null, BSRegister
::GetType('Date'));
126 public function testRequiredModules()
128 BSRegister
::RequiredModules(array('Input'));
129 $this->assertNoErrors();
131 BSRegister
::RequiredModules(array('Input', 'Db'));
132 $this->assertError();
134 BSRegister
::RequiredModules(array('Date'));
135 $this->assertError();