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::Registry()->someKey = 'someValue';
$registry = BSRegister::Registry();
$this->assertEquals($registry->someKey, 'someValue');
}
public function testGetAll()
{
BSRegister::Registry()->test = 1;
$this->assertType('array', BSRegister::Registry()->allObjects());
$this->assertSame(sizeof(BSRegister::Registry()->allObjects()), 2);
}
public function testOverWriteRegister()
{
BSRegister::Registry()->valueToOverWrite = 1;
BSRegister::Registry()->valueToOverWrite = 2;
$this->assertEquals(2, BSRegister::Registry()->valueToOverWrite);
}
public function testGet()
{
BSRegister::Registry()->testGet = 123;
$this->assertEquals(123, BSRegister::Registry()->testGet);
}
public function testUnregister()
{
BSRegister::Registry()->testUnregister = 1;
unset(BSRegister::Registry()->testUnregister);
$this->assertObjectNotHasAttribute('testUnregister', BSRegister::Registry());
}
public function testGetNoExist()
{
try
{
BSRegister::Registry()->doesNotExist;
$this->fail('exception expected');
}
catch (Exception $e)
{}
}
public function testUnregisterNoExist()
{
try
{
unset(BSRegister::Registry()->keyThatWontExist);
$this->fail('exception expected');
}
catch (Exception $e)
{}
}
public function testGetType()
{
$input = BSRegister::LoadModule('Input');
BSRegister::Registry()->input = $input;
$this->assertSame($input, BSRegister::Registry()->getType('Input'));
$this->assertEquals(null, BSRegister::Registry()->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)
{}
}
}
?>