Updating the unit tests for preparation of renaming BSRegister to BSApp
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 14 Aug 2007 03:42:12 +0000 (03:42 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 14 Aug 2007 03:42:12 +0000 (03:42 +0000)
docs/UnitTest/AllTests.php
docs/UnitTest/AppTest.php [new file with mode: 0644]
docs/UnitTest/DatabaseMySQLTest.php
docs/UnitTest/DatabaseMySQLiTest.php
docs/UnitTest/DateTest.php
docs/UnitTest/FunctionsTest.php
docs/UnitTest/InputTest.php
docs/UnitTest/RegisterTest.php [deleted file]

index 6bb6bb067dc02a151107a84b495c36841f43aaf3..063e495e19cd33a60426feace013b3c05fb8c04c 100644 (file)
@@ -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 (file)
index 0000000..f7c692b
--- /dev/null
@@ -0,0 +1,172 @@
+<?php
+
+require_once 'PHPUnit/Framework.php';
+
+
+/**
+* Application Test Suite
+*
+* @author              Blue Static
+* @copyright   Copyright ©2002 - [#]year[#], Blue Static
+* @version             $Revision$
+* @package             ISSO Tests
+* 
+*/
+class AppTest extends PHPUnit_Framework_TestCase
+{
+       public function setUp()
+       {
+               require_once 'ISSO/Register.php';
+       }
+       
+       public function testLoadModule()
+       {
+               $this->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('<select><option>Debug Notices (0)</option></select>', BSApp::GetDebugList());
+               
+               BSApp::Debug('dbg');
+               $this->assertEquals('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', 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
index 0825de6c8e68942a6253f1797016f123f9da86cd..d3cf1c570342437e147b48dfa32d73059c12050e 100644 (file)
@@ -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)
index 86e2513e3a1f1c60745cd732daa52795777f6ee9..63e850936d6b6253ae8d59a94e8a19c3bdd67d22 100644 (file)
@@ -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)
index 05aa9eb6898bf1c8812b7c9a32bb2bcbbf04bf1f..2008cb08923c04a46c77487202a5f86039fc88d0 100644 (file)
@@ -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()
index b7c642540daf0b4b5d3553ae1ccfe84ed9911f3f..59c9cf79aac13940e000c6b5b6c70d4f861caeba 100644 (file)
@@ -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()
index 7ff5887f03974189430cd883be979b65eaaa0dad..b2bc4a2eb038e68b60b257c80bc724076bd25e8c 100644 (file)
@@ -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 (file)
index 7496d73..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-<?php
-
-require_once 'PHPUnit/Framework.php';
-
-
-/**
-* Register Test Suite
-*
-* @author              Blue Static
-* @copyright   Copyright ©2002 - [#]year[#], Blue Static
-* @version             $Revision$
-* @package             ISSO Tests
-* 
-*/
-class RegisterTest extends PHPUnit_Framework_TestCase
-{
-       public function setUp()
-       {
-               require_once 'ISSO/Register.php';
-       }
-       
-       public function testLoadModule()
-       {
-               $this->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('<select><option>Debug Notices (0)</option></select>', BSRegister::GetDebugList());
-               
-               BSRegister::Debug('dbg');
-               $this->assertEquals('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', 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