set_magic_quotes_runtime(0);
// some debug info that's always useful
- BSRegister::Instance()->debug('magic_quotes_gpc = ' . $this->magicquotes);
- BSRegister::Instance()->debug('register_globals = ' . ini_get('register_globals'));
+ BSRegister::Debug('magic_quotes_gpc = ' . $this->magicquotes);
+ BSRegister::Debug('register_globals = ' . ini_get('register_globals'));
$this->sanitizeInputData();
trigger_error('No external hosts are allowed to POST to this application');
exit;
}
- BSRegister::Instance()->debug('remote post check = ok');
+ BSRegister::Debug('remote post check = ok');
}
else
{
- BSRegister::Instance()->debug('remote post check = FAILED');
+ BSRegister::Debug('remote post check = FAILED');
}
}
}
*
* @return object BSRegister instance
*/
- public static function Instance()
+ private static function Instance()
{
if (self::$instance == null)
{
*
* @param string Application name
*/
- public function setApplication($name)
+ public static function SetApplication($name)
{
- $this->application = $name;
+ self::Instance()->application = $name;
}
// ###################################################################
*
* @return string Application name
*/
- public function getApplication()
+ public static function GetApplication()
{
- return $this->application;
+ return self::Instance()->application;
}
// ###################################################################
*
* @param string Path
*/
- public function setAppPath($path)
+ public static function SetAppPath($path)
{
- $this->appPath = BSFunctions::FetchSourcePath($path);
+ self::Instance()->appPath = BSFunctions::FetchSourcePath($path);
}
// ###################################################################
*
* @return string Application path
*/
- public function getAppPath()
+ public static function GetAppPath()
{
- return $this->appPath;
+ return self::Instance()->appPath;
}
// ###################################################################
*
* @param string Application version
*/
- public function setAppVersion($vers)
+ public static function SetAppVersion($vers)
{
- $this->appVersion = $vers;
+ self::Instance()->appVersion = $vers;
}
// ###################################################################
*
* @return string Application version
*/
- public function getAppVersion()
+ public static function GetAppVersion()
{
- return $this->appVersion;
+ return self::Instance()->appVersion;
}
// ###################################################################
*
* @param string Path
*/
- public function setWebPath($path)
+ public static function SetWebPath($path)
{
- $this->webPath = BSFunctions::FetchSourcePath($path);
+ self::Instance()->webPath = BSFunctions::FetchSourcePath($path);
}
// ###################################################################
*
* @return string Application's web path
*/
- public function getWebPath()
+ public static function GetWebPath()
{
- return $this->webPath;
+ return self::Instance()->webPath;
}
// ###################################################################
*
* @param bool Debug mode on?
*/
- public function setDebug($debug)
+ public static function SetDebug($debug)
{
- $this->debug = $debug;
+ self::Instance()->debug = $debug;
}
// ###################################################################
*
* @return bool Debug mode on?
*/
- public function getDebug()
+ public static function GetDebug()
{
- return $this->debug;
+ return self::Instance()->debug;
}
// ###################################################################
* @param string Registry key
* @param mixed Value to register
*/
- public function register($key, $value)
+ public static function Register($key, $value)
{
- if (isset($this->registry["$key"]))
+ if (isset(self::Instance()->registry["$key"]))
{
trigger_error('Cannot overwrite a key in the registry');
return;
}
- $this->registry["$key"] = $value;
+ self::Instance()->registry["$key"] = $value;
}
// ###################################################################
*
* @param string Registry key
*/
- public function unregister($key)
+ public static function Unregister($key)
{
- if (!isset($this->registry["$key"]))
+ if (!isset(self::Instance()->registry["$key"]))
{
trigger_error('You cannot unregister a key that does not exist');
return;
}
- unset($this->registry["$key"]);
+ unset(self::Instance()->registry["$key"]);
}
// ###################################################################
*
* @return mixed Value in the registry for key
*/
- public function get($key)
+ public static function Get($key)
{
- if (!isset($this->registry["$key"]))
+ if (!isset(self::Instance()->registry["$key"]))
{
trigger_error('Cannot access the registry with a non-existent key');
return;
}
- return $this->registry["$key"];
+ return self::Instance()->registry["$key"];
}
// ###################################################################
*
* @return array Complete registry
*/
- public function getAll()
+ public static function GetAll()
{
- return $this->registry;
+ return self::Instance()->registry;
}
// ###################################################################
*
* @param string Debug message
*/
- public function debug($msg)
+ public static function Debug($msg)
{
- if ($this->debug)
+ if (self::Instance()->debug)
{
- $this->debugInfo[] = $msg;
+ self::Instance()->debugInfo[] = $msg;
}
}
*
*/
class RegisterTest extends UnitTestCase
-{
- protected $fixture;
-
- public function setUp()
- {
- $this->fixture = BSRegister::Instance();
- }
-
- public function testNewRegister()
- {
- $this->assertTrue($this->fixture instanceof BSRegister);
- $this->assertReference($this->fixture, BSRegister::Instance());
- }
-
+{
public function testLoadModule()
{
$this->assertTrue(BSRegister::LoadModule('Input') instanceof BSInput);
public function testSetGetAppPath()
{
- $this->fixture->setAppPath(getcwd());
- $this->assertEqual(getcwd() . DIRECTORY_SEPARATOR, $this->fixture->getAppPath());
+ BSRegister::SetAppPath(getcwd());
+ $this->assertEqual(getcwd() . DIRECTORY_SEPARATOR, BSRegister::GetAppPath());
}
public function testSetGetAppVersion()
{
- $this->fixture->setAppVersion('1.0-test');
- $this->assertEqual('1.0-test', $this->fixture->getAppVersion());
+ BSRegister::SetAppVersion('1.0-test');
+ $this->assertEqual('1.0-test', BSRegister::GetAppVersion());
}
public function testSetGetApplication()
{
- $this->fixture->setApplication('ISSO Tests');
- $this->assertEqual('ISSO Tests', $this->fixture->getApplication());
+ BSRegister::SetApplication('ISSO Tests');
+ $this->assertEqual('ISSO Tests', BSRegister::GetApplication());
}
public function testSetGetWebPath()
{
$path = DIRECTORY_SEPARATOR . 'Server' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR . 'ISSO';
- $this->fixture->setWebPath($path);
- $this->assertEqual($path . DIRECTORY_SEPARATOR, $this->fixture->getWebPath());
+ BSRegister::SetWebPath($path);
+ $this->assertEqual($path . DIRECTORY_SEPARATOR, BSRegister::GetWebPath());
}
public function testSetGetDebug()
{
- $this->fixture->setDebug(true);
- $this->assertIdentical(true, $this->fixture->getDebug());
+ BSRegister::SetDebug(true);
+ $this->assertIdentical(true, BSRegister::GetDebug());
}
public function testRegisterValue()
{
- $this->fixture->register('someKey', 'someValue');
+ BSRegister::Register('someKey', 'someValue');
- $registry = $this->fixture->getAll();
+ $registry = BSRegister::GetAll();
$this->assertEqual($registry['someKey'], 'someValue');
}
public function testGetAll()
{
- $this->fixture->register('test', 1);
- $this->assertIsA($this->fixture->getAll(), 'array');
- $this->assertEqual(sizeof($this->fixture->getAll()), 2);
+ BSRegister::Register('test', 1);
+ $this->assertIsA(BSRegister::GetAll(), 'array');
+ $this->assertEqual(sizeof(BSRegister::GetAll()), 2);
}
public function testOverWriteRegister()
{
- $this->fixture->register('valueToOverWrite', 1);
- $this->fixture->register('valueToOverWrite', 2);
+ BSRegister::Register('valueToOverWrite', 1);
+ BSRegister::Register('valueToOverWrite', 2);
$this->assertError();
- $this->assertEqual(1, $this->fixture->get('valueToOverWrite'));
+ $this->assertEqual(1, BSRegister::Get('valueToOverWrite'));
}
public function testGet()
{
- $this->fixture->register('testGet', 123);
- $this->assertEqual(123, $this->fixture->get('testGet'));
+ BSRegister::Register('testGet', 123);
+ $this->assertEqual(123, BSRegister::Get('testGet'));
}
public function testUnregister()
{
- $this->fixture->register('testUnregister', 1);
- $this->fixture->unregister('testUnregister');
- $this->fixture->register('testUnregister', 2);
+ BSRegister::Register('testUnregister', 1);
+ BSRegister::Unregister('testUnregister');
+ BSRegister::Register('testUnregister', 2);
$this->assertNoErrors();
- $this->assertEqual(2, $this->fixture->get('testUnregister'));
+ $this->assertEqual(2, BSRegister::Get('testUnregister'));
}
public function testGetNoExist()
{
- $this->fixture->get('doesNotExist');
+ BSRegister::Get('doesNotExist');
$this->assertError();
}
public function testUnregisterNoExist()
{
- $this->fixture->unregister('keyThatWontExist');
+ BSRegister::Unregister('keyThatWontExist');
$this->assertError();
}
}