From daf228c8b753495f95a0ae02800624604fea01cc Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 14 Aug 2007 03:42:12 +0000 Subject: [PATCH] Updating the unit tests for preparation of renaming BSRegister to BSApp --- docs/UnitTest/AllTests.php | 4 +- docs/UnitTest/AppTest.php | 172 +++++++++++++++++++++++++++ docs/UnitTest/DatabaseMySQLTest.php | 6 +- docs/UnitTest/DatabaseMySQLiTest.php | 6 +- docs/UnitTest/DateTest.php | 4 +- docs/UnitTest/FunctionsTest.php | 2 +- docs/UnitTest/InputTest.php | 4 +- docs/UnitTest/RegisterTest.php | 172 --------------------------- 8 files changed, 185 insertions(+), 185 deletions(-) create mode 100644 docs/UnitTest/AppTest.php delete mode 100644 docs/UnitTest/RegisterTest.php diff --git a/docs/UnitTest/AllTests.php b/docs/UnitTest/AllTests.php index 6bb6bb0..063e495 100644 --- a/docs/UnitTest/AllTests.php +++ b/docs/UnitTest/AllTests.php @@ -31,8 +31,8 @@ class AllTests require_once 'InputTest.php'; $suite->addTestSuite('InputTest'); - require_once 'RegisterTest.php'; - $suite->addTestSuite('RegisterTest'); + require_once 'AppTest.php'; + $suite->addTestSuite('AppTest'); require_once 'XmlTest.php'; $suite->addTestSuite('XmlTest'); diff --git a/docs/UnitTest/AppTest.php b/docs/UnitTest/AppTest.php new file mode 100644 index 0000000..f7c692b --- /dev/null +++ b/docs/UnitTest/AppTest.php @@ -0,0 +1,172 @@ +assertTrue(BSApp::LoadModule('Input') instanceof BSInput); + } + + public function testLoadBadModule() + { + try + { + BSApp::LoadModule('nonExistentModule'); + $this->fail('exception expected'); + } + catch (Exception $e) + {} + } + + public function testSetGetAppPath() + { + BSApp::SetAppPath(getcwd()); + $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR, BSApp::GetAppPath()); + } + + public function testSetGetAppVersion() + { + BSApp::SetAppVersion('1.0-test'); + $this->assertEquals('1.0-test', BSApp::GetAppVersion()); + } + + public function testSetGetApplication() + { + BSApp::SetApplication('ISSO Tests'); + $this->assertEquals('ISSO Tests', BSApp::GetApplication()); + } + + public function testSetGetWebPath() + { + $path = DIRECTORY_SEPARATOR . 'Server' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR . 'ISSO'; + BSApp::SetWebPath($path); + $this->assertEquals($path . DIRECTORY_SEPARATOR, BSApp::GetWebPath()); + } + + public function testSetGetDebug() + { + BSApp::SetDebug(true); + $this->assertSame(true, BSApp::GetDebug()); + } + + public function testDebugList() + { + $this->assertEquals('', BSApp::GetDebugList()); + + BSApp::Debug('dbg'); + $this->assertEquals('', BSApp::GetDebugList()); + } + + public function testRegisterValue() + { + BSApp::Registry()->someKey = 'someValue'; + + $registry = BSApp::Registry(); + $this->assertEquals($registry->someKey, 'someValue'); + } + + public function testGetAll() + { + BSApp::Registry()->test = 1; + $this->assertType('array', BSApp::Registry()->allObjects()); + $this->assertSame(sizeof(BSApp::Registry()->allObjects()), 2); + } + + public function testOverWriteRegister() + { + BSApp::Registry()->valueToOverWrite = 1; + BSApp::Registry()->valueToOverWrite = 2; + $this->assertEquals(2, BSApp::Registry()->valueToOverWrite); + } + + public function testGet() + { + BSApp::Registry()->testGet = 123; + $this->assertEquals(123, BSApp::Registry()->testGet); + } + + public function testUnregister() + { + BSApp::Registry()->testUnregister = 1; + unset(BSApp::Registry()->testUnregister); + $this->assertObjectNotHasAttribute('testUnregister', BSApp::Registry()); + } + + public function testGetNoExist() + { + try + { + BSApp::Registry()->doesNotExist; + $this->fail('exception expected'); + } + catch (Exception $e) + {} + } + + public function testUnregisterNoExist() + { + try + { + unset(BSApp::Registry()->keyThatWontExist); + $this->fail('exception expected'); + } + catch (Exception $e) + {} + } + + public function testGetType() + { + $input = BSApp::LoadModule('Input'); + BSApp::Registry()->input = $input; + $this->assertSame($input, BSApp::Registry()->getType('Input')); + + $this->assertEquals(null, BSApp::Registry()->getType('Date')); + } + + public function testRequiredModules() + { + try + { + BSApp::RequiredModules(array('Input')); + } + catch (Exception $e) + { + $this->fail('unexpcted exception'); + } + + try + { + BSApp::RequiredModules(array('Input', 'Db')); + $this->fail('exception expected'); + } + catch (Exception $e) + {} + + try + { + BSApp::RequiredModules(array('Date')); + $this->fail('exception expected'); + } + catch (Exception $e) + {} + } +} + +?> \ No newline at end of file diff --git a/docs/UnitTest/DatabaseMySQLTest.php b/docs/UnitTest/DatabaseMySQLTest.php index 0825de6..d3cf1c5 100644 --- a/docs/UnitTest/DatabaseMySQLTest.php +++ b/docs/UnitTest/DatabaseMySQLTest.php @@ -8,9 +8,9 @@ class DatabaseMySQLTest extends DatabaseTestAbstract public function setUp() { require_once 'tests.config.php'; - require_once 'ISSO/Register.php'; + require_once 'ISSO/App.php'; - $this->fixture = BSRegister::LoadModule('DbMySql'); + $this->fixture = BSApp::LoadModule('DbMySql'); $this->fixture->connect(TEST_DB_MYSQL_HOST, TEST_DB_MYSQL_USER, TEST_DB_MYSQL_PASSWORD, TEST_DB_MYSQL_DATABASE); $this->fixture->query(" CREATE TABLE test @@ -32,7 +32,7 @@ class DatabaseMySQLTest extends DatabaseTestAbstract { try { - BSRegister::LoadModule('DbMySql')->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--'); + BSApp::LoadModule('DbMySql')->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--'); $this->fail('exception expected'); } catch (BSDbException $e) diff --git a/docs/UnitTest/DatabaseMySQLiTest.php b/docs/UnitTest/DatabaseMySQLiTest.php index 86e2513..63e8509 100644 --- a/docs/UnitTest/DatabaseMySQLiTest.php +++ b/docs/UnitTest/DatabaseMySQLiTest.php @@ -8,9 +8,9 @@ class DatabaseMySQLiTest extends DatabaseTestAbstract public function setUp() { require_once 'tests.config.php'; - require_once 'ISSO/Register.php'; + require_once 'ISSO/App.php'; - $this->fixture = BSRegister::LoadModule('DbMySqlI'); + $this->fixture = BSApp::LoadModule('DbMySqlI'); $this->fixture->connect(TEST_DB_MYSQL_HOST, TEST_DB_MYSQL_USER, TEST_DB_MYSQL_PASSWORD, TEST_DB_MYSQL_DATABASE); $this->fixture->query(" CREATE TABLE test @@ -32,7 +32,7 @@ class DatabaseMySQLiTest extends DatabaseTestAbstract { try { - BSRegister::LoadModule('DbMySqlI')->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--'); + BSApp::LoadModule('DbMySqlI')->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--'); $this->fail('exception expected'); } catch (BSDbException $e) diff --git a/docs/UnitTest/DateTest.php b/docs/UnitTest/DateTest.php index 05aa9eb..2008cb0 100644 --- a/docs/UnitTest/DateTest.php +++ b/docs/UnitTest/DateTest.php @@ -19,8 +19,8 @@ class DateTest extends PHPUnit_Framework_TestCase public function setUp() { - require_once 'ISSO/Register.php'; - $this->fixture = BSRegister::LoadModule('Date'); + require_once 'ISSO/App.php'; + $this->fixture = BSApp::LoadModule('Date'); } public function testGmtTimes() diff --git a/docs/UnitTest/FunctionsTest.php b/docs/UnitTest/FunctionsTest.php index b7c6425..59c9cf7 100644 --- a/docs/UnitTest/FunctionsTest.php +++ b/docs/UnitTest/FunctionsTest.php @@ -15,7 +15,7 @@ class FunctionsTest extends PHPUnit_Framework_TestCase { public function setUp() { - require_once('ISSO/Register.php'); + require_once('ISSO/App.php'); } public function testSwapCssClasses() diff --git a/docs/UnitTest/InputTest.php b/docs/UnitTest/InputTest.php index 7ff5887..b2bc4a2 100644 --- a/docs/UnitTest/InputTest.php +++ b/docs/UnitTest/InputTest.php @@ -46,8 +46,8 @@ class InputTest extends PHPUnit_Framework_TestCase } }*/ - require_once 'ISSO/Register.php'; - $this->fixture = BSRegister::LoadModule('Input'); + require_once 'ISSO/App.php'; + $this->fixture = BSApp::LoadModule('Input'); } public function testSanitizeInputData() diff --git a/docs/UnitTest/RegisterTest.php b/docs/UnitTest/RegisterTest.php deleted file mode 100644 index 7496d73..0000000 --- a/docs/UnitTest/RegisterTest.php +++ /dev/null @@ -1,172 +0,0 @@ -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) - {} - } -} - -?> \ No newline at end of file -- 2.22.5