3 require_once 'PHPUnit/Framework.php';
10 * @copyright Copyright ©2002 - [#]year[#], Blue Static
15 class RegisterTest
extends PHPUnit_Framework_TestCase
17 public function setUp()
19 require_once 'ISSO/Register.php';
22 public function testLoadModule()
24 $this->assertTrue(BSRegister
::LoadModule('Input') instanceof BSInput
);
27 public function testLoadBadModule()
31 BSRegister
::LoadModule('nonExistentModule');
32 $this->fail('exception expected');
38 public function testSetGetAppPath()
40 BSRegister
::SetAppPath(getcwd());
41 $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR
, BSRegister
::GetAppPath());
44 public function testSetGetAppVersion()
46 BSRegister
::SetAppVersion('1.0-test');
47 $this->assertEquals('1.0-test', BSRegister
::GetAppVersion());
50 public function testSetGetApplication()
52 BSRegister
::SetApplication('ISSO Tests');
53 $this->assertEquals('ISSO Tests', BSRegister
::GetApplication());
56 public function testSetGetWebPath()
58 $path = DIRECTORY_SEPARATOR
. 'Server' . DIRECTORY_SEPARATOR
. 'htdocs' . DIRECTORY_SEPARATOR
. 'ISSO';
59 BSRegister
::SetWebPath($path);
60 $this->assertEquals($path . DIRECTORY_SEPARATOR
, BSRegister
::GetWebPath());
63 public function testSetGetDebug()
65 BSRegister
::SetDebug(true
);
66 $this->assertSame(true
, BSRegister
::GetDebug());
69 public function testDebugList()
71 $this->assertEquals('<select><option>Debug Notices (0)</option></select>', BSRegister
::GetDebugList());
73 BSRegister
::Debug('dbg');
74 $this->assertEquals('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', BSRegister
::GetDebugList());
77 public function testRegisterValue()
79 BSRegister
::Register('someKey', 'someValue');
81 $registry = BSRegister
::GetAll();
82 $this->assertEquals($registry['someKey'], 'someValue');
85 public function testGetAll()
87 BSRegister
::Register('test', 1);
88 $this->assertType('array', BSRegister
::GetAll());
89 $this->assertEquals(sizeof(BSRegister
::GetAll()), 2);
92 public function testOverWriteRegister()
96 BSRegister
::Register('valueToOverWrite', 1);
97 BSRegister
::Register('valueToOverWrite', 2);
98 $this->fail('exception expected');
102 $this->assertEquals(1, BSRegister
::Get('valueToOverWrite'));
106 public function testGet()
108 BSRegister
::Register('testGet', 123);
109 $this->assertEquals(123, BSRegister
::Get('testGet'));
112 public function testUnregister()
116 BSRegister
::Register('testUnregister', 1);
117 BSRegister
::Unregister('testUnregister');
118 BSRegister
::Register('testUnregister', 2);
119 $this->fail('exception expected');
123 $this->assertEquals(2, BSRegister
::Get('testUnregister'));
127 public function testGetNoExist()
131 BSRegister
::Get('doesNotExist');
132 $this->fail('exception expected');
138 public function testUnregisterNoExist()
142 BSRegister
::Unregister('keyThatWontExist');
143 $this->fail('exception expected');
149 public function testGetType()
151 $input = BSRegister
::LoadModule('Input');
152 BSRegister
::Register('input', $input);
153 $this->assertSame($input, BSRegister
::GetType('Input'));
155 $this->assertEquals(null
, BSRegister
::GetType('Date'));
158 public function testRequiredModules()
162 BSRegister
::RequiredModules(array('Input'));
166 $this->fail('unexpcted exception');
171 BSRegister
::RequiredModules(array('Input', 'Db'));
172 $this->fail('exception expected');
179 BSRegister
::RequiredModules(array('Date'));
180 $this->fail('exception expected');