assertTrue(BSRegister::LoadModule('Input') instanceof BSInput); } public function testLoadBadModule() { try { BSRegister::LoadModule('nonExistentModule'); $this->fail('exception expected'); } catch (Exception $e) {} } public function testSetGetAppPath() { BSRegister::SetAppPath(getcwd()); $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR, BSRegister::GetAppPath()); } public function testSetGetAppVersion() { BSRegister::SetAppVersion('1.0-test'); $this->assertEquals('1.0-test', BSRegister::GetAppVersion()); } public function testSetGetApplication() { BSRegister::SetApplication('ISSO Tests'); $this->assertEquals('ISSO Tests', BSRegister::GetApplication()); } public function testSetGetWebPath() { $path = DIRECTORY_SEPARATOR . 'Server' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR . 'ISSO'; BSRegister::SetWebPath($path); $this->assertEquals($path . DIRECTORY_SEPARATOR, BSRegister::GetWebPath()); } public function testSetGetDebug() { BSRegister::SetDebug(true); $this->assertSame(true, BSRegister::GetDebug()); } public function testDebugList() { $this->assertEquals('', BSRegister::GetDebugList()); BSRegister::Debug('dbg'); $this->assertEquals('', BSRegister::GetDebugList()); } public function testRegisterValue() { BSRegister::Register('someKey', 'someValue'); $registry = BSRegister::GetAll(); $this->assertEquals($registry['someKey'], 'someValue'); } public function testGetAll() { BSRegister::Register('test', 1); $this->assertType('array', BSRegister::GetAll()); $this->assertEquals(sizeof(BSRegister::GetAll()), 2); } public function testOverWriteRegister() { try { BSRegister::Register('valueToOverWrite', 1); BSRegister::Register('valueToOverWrite', 2); $this->fail('exception expected'); } catch (Exception $e) { $this->assertEquals(1, BSRegister::Get('valueToOverWrite')); } } public function testGet() { BSRegister::Register('testGet', 123); $this->assertEquals(123, BSRegister::Get('testGet')); } public function testUnregister() { try { BSRegister::Register('testUnregister', 1); BSRegister::Unregister('testUnregister'); BSRegister::Register('testUnregister', 2); $this->fail('exception expected'); } catch (Exception $e) { $this->assertEquals(2, BSRegister::Get('testUnregister')); } } public function testGetNoExist() { try { BSRegister::Get('doesNotExist'); $this->fail('exception expected'); } catch (Exception $e) {} } public function testUnregisterNoExist() { try { BSRegister::Unregister('keyThatWontExist'); $this->fail('exception expected'); } catch (Exception $e) {} } public function testGetType() { $input = BSRegister::LoadModule('Input'); BSRegister::Register('input', $input); $this->assertSame($input, BSRegister::GetType('Input')); $this->assertEquals(null, BSRegister::GetType('Date')); } public function testRequiredModules() { try { BSRegister::RequiredModules(array('Input')); } catch (Exception $e) { $this->fail('unexpcted exception'); } try { BSRegister::RequiredModules(array('Input', 'Db')); $this->fail('exception expected'); } catch (Exception $e) {} try { BSRegister::RequiredModules(array('Date')); $this->fail('exception expected'); } catch (Exception $e) {} } } ?>