Adding fixes in the unit tests for all the refactoring we did
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 13 Jan 2008 22:11:46 +0000 (14:11 -0800)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 13 Jan 2008 22:11:46 +0000 (14:11 -0800)
Date.php
UnitTest/ApiTest.php
UnitTest/AppTest.php
UnitTest/DatabaseMySQLTest.php
UnitTest/DatabaseMySQLiTest.php
UnitTest/DateTest.php
UnitTest/FunctionsTest.php
UnitTest/InputTest.php
UnitTest/InstallerTest.php
UnitTest/TemplateTest.php

index 714539906decdb831a2cd83089d3c5e2fc3f4ab4..5761b03eaa6e51f3d495b7601ac870ffa823494c 100644 (file)
--- a/Date.php
+++ b/Date.php
@@ -87,7 +87,7 @@ class BSDate
        *
        * @return       array   List of timezones
        */
-       public static function fetch_time_zone_list()
+       public static function fetch_timezone_list()
        {
                $opt = array();
                
index cdb25178cde1b12a357602dd8b20f4d8be3faff2..2caa68bef0235f91f06c1c2818e23a7245a0f661 100644 (file)
@@ -2,6 +2,7 @@
 
 require_once 'PHPUnit/Framework.php';
 require_once ISSO . '/Api.php';
+require_once ISSO . '/DbMySql.php';
 
 /**
  * ApiTest
@@ -18,7 +19,7 @@ class ApiTest extends PHPUnit_Framework_TestCase
        
        public function setUp()
        {
-               $this->db = BSApp::LoadModule('DbMySql');
+               BSApp::$db = $this->db = new BSDbMySql();
                $this->db->connect(TEST_DB_MYSQL_HOST, TEST_DB_MYSQL_USER, TEST_DB_MYSQL_PASSWORD, TEST_DB_MYSQL_DATABASE);
                $this->fixture = new TestApiFixture();
                
index 6130ccfe271780f86d9e4e0bf181be2e4f2d960d..6b7926918d0d4ad5fe5886c0fa8f5a2fb644b567 100644 (file)
@@ -18,153 +18,18 @@ class AppTest extends PHPUnit_Framework_TestCase
                require_once ISSO . '/App.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());
+               BSApp::set_debug(true);
+               $this->assertSame(true, BSApp::get_debug());
        }
        
        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()), 3);
-       }
-       
-       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)
-               {}
+               $this->assertEquals('<select><option>Debug Notices (0)</option></select>', BSApp::get_debug_list());
                
-               try
-               {
-                       BSApp::RequiredModules(array('Date'));
-                       $this->fail('exception expected');
-               }
-               catch (Exception $e)
-               {}
+               BSApp::debug('dbg');
+               $this->assertEquals('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', BSApp::get_debug_list());
        }
 }
 
index 1f68604308497109547112dc76395dd8f6317311..a7746eb4365d0d6fcf12fd2edbc363b53092284d 100644 (file)
@@ -10,7 +10,7 @@ class DatabaseMySQLTest extends DatabaseTestAbstract
                require_once 'tests.config.php';
                require_once ISSO . '/App.php';
                
-               $this->fixture = BSApp::LoadModule('DbMySql');
+               $this->fixture = new BSDbMySql();
                $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,8 @@ class DatabaseMySQLTest extends DatabaseTestAbstract
        {
                try
                {
-                       BSApp::LoadModule('DbMySql')->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--');
+                       $test = new BSDbMySql();
+                       $test->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--');
                        $this->fail('exception expected');
                }
                catch (BSDbException $e)
index 84c6c53053d6a041427bf8ff7653f475dc9686dd..88907fd0e4a8de1a9ec457d34cfc378c07abdd09 100644 (file)
@@ -9,8 +9,9 @@ class DatabaseMySQLiTest extends DatabaseTestAbstract
        {
                require_once 'tests.config.php';
                require_once ISSO . '/App.php';
+               require_once ISSO . '/DbMySqlI.php';
                
-               $this->fixture = BSApp::LoadModule('DbMySqlI');
+               $this->fixture = new BSDbMySqlI();
                $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 +33,8 @@ class DatabaseMySQLiTest extends DatabaseTestAbstract
        {
                try
                {
-                       BSApp::LoadModule('DbMySqlI')->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--');
+                       $test = new BSDbMySqlI();
+                       $test->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--');
                        $this->fail('exception expected');
                }
                catch (BSDbException $e)
index 8aa42dfe4aab1df8f13ea38d1017ff8b108842da..e0c7609606cf03222e7ccc7de4df27f8baab1163 100644 (file)
@@ -19,7 +19,8 @@ class DateTest extends PHPUnit_Framework_TestCase
        public function setUp()
        {
                require_once ISSO . '/App.php';
-               $this->fixture = BSApp::LoadModule('Date');
+               require_once ISSO . '/Date.php';
+               $this->fixture = new BSDate();
        }
        
        public function testGmtTimes()
@@ -43,7 +44,7 @@ class DateTest extends PHPUnit_Framework_TestCase
        
        public function testTimezoneList()
        {
-               $this->assertEquals(sizeof(BSDate::FetchTimeZoneList()), 30);
+               $this->assertEquals(sizeof(BSDate::fetch_timezone_list()), 30);
        }
 }
 
index 269b29eb621492a8f57c703a9e64fb2dce1fca6a..0356a5301e477f0f498480cb199d17d9440c43be 100644 (file)
@@ -21,19 +21,19 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
        {
                $this->assertEquals('', BSFunctions::$cssClass);
                
-               BSFunctions::SwapCssClasses('1', '2');
+               BSFunctions::swap_css_classes('1', '2');
                $this->assertEquals('2', BSFunctions::$cssClass);
                
-               BSFunctions::SwapCssClasses('1', '2');
+               BSFunctions::swap_css_classes('1', '2');
                $this->assertEquals('1', BSFunctions::$cssClass);
                
-               BSFunctions::SwapCssClasses('1', '2');
+               BSFunctions::swap_css_classes('1', '2');
                $this->assertEquals('2', BSFunctions::$cssClass);
        }
        
        public function testFetchSourcePath()
        {
-               $this->assertEquals('a' . DIRECTORY_SEPARATOR, BSFunctions::FetchSourcePath('a'));
+               $this->assertEquals('a' . DIRECTORY_SEPARATOR, BSFunctions::fetch_source_path('a'));
        }
        
        public function testDownloadFile()
@@ -43,14 +43,14 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
        
        public function testIsValidEmail()
        {
-               $this->assertTrue(BSFunctions::IsValidEmail('test@example.com'));
-               $this->assertTrue(BSFunctions::IsValidEmail('test@example.co.uk'));
-               $this->assertTrue(BSFunctions::IsValidEmail('test.foo_hi@example.edu.k12.paloalto.ca.us'));
+               $this->assertTrue(BSFunctions::is_valid_email('test@example.com'));
+               $this->assertTrue(BSFunctions::is_valid_email('test@example.co.uk'));
+               $this->assertTrue(BSFunctions::is_valid_email('test.foo_hi@example.edu.k12.paloalto.ca.us'));
                
-               $this->assertFalse(BSFunctions::IsValidEmail(''));
-               $this->assertFalse(BSFunctions::IsValidEmail('te#st@example.com'));
-               $this->assertFalse(BSFunctions::IsValidEmail('@example.com'));
-               $this->assertFalse(BSFunctions::IsValidEmail('test@.com'));
+               $this->assertFalse(BSFunctions::is_valid_email(''));
+               $this->assertFalse(BSFunctions::is_valid_email('te#st@example.com'));
+               $this->assertFalse(BSFunctions::is_valid_email('@example.com'));
+               $this->assertFalse(BSFunctions::is_valid_email('test@.com'));
        }
        
        public function testIsBrowser()
@@ -63,7 +63,7 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
                $values = array();
                for ($i = 0; $i < 100; $i++)
                {
-                       $random = BSFunctions::Random(5);
+                       $random = BSFunctions::random(5);
                        $this->assertEquals(5, strlen($random));
                        $this->assertFalse(in_array($random, $values));
                        $values[] = $random;
@@ -78,10 +78,10 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
                $this->assertEquals('b', next($array));
                $this->assertEquals('c', next($array));
                
-               BSFunctions::ArraySetCurrent($array, 0);
+               BSFunctions::array_set_current($array, 0);
                $this->assertEquals('a', current($array));
                
-               BSFunctions::ArraySetCurrent($array, 3);
+               BSFunctions::array_set_current($array, 3);
                $this->assertEquals('d', current($array));
        }
        
@@ -92,9 +92,9 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
        
        public function testFetchExtension()
        {
-               $this->assertEquals('txt', BSFunctions::FetchExtension('test.txt'));
-               $this->assertEquals('', BSFunctions::FetchExtension('test'));
-               $this->assertEquals('xml', BSFunctions::FetchExtension('test.file.xml'));
+               $this->assertEquals('txt', BSFunctions::fetch_extension('test.txt'));
+               $this->assertEquals('', BSFunctions::fetch_extension('test'));
+               $this->assertEquals('xml', BSFunctions::fetch_extension('test.file.xml'));
        }
        
        public function testFetchMaxPhpFileSize()
@@ -110,19 +110,19 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
        public function testConvertLineBreaks()
        {
                $string = "test\r\nstring\r\n";
-               $this->assertFalse(strpos("\r", BSFunctions::ConvertLineBreaks($string)));
+               $this->assertFalse(strpos("\r", BSFunctions::convert_line_breaks($string)));
        }
        
        public function testArrayStripEmpty()
        {
                $array = array(1, 4, 6);
-               $this->assertEquals(3, sizeof(BSFunctions::ArrayStripEmpty($array)));
+               $this->assertEquals(3, sizeof(BSFunctions::array_strip_empty($array)));
                
                $array = array(1, 0, 5, '');
-               $this->assertEquals(2, sizeof(BSFunctions::ArrayStripEmpty($array)));
+               $this->assertEquals(2, sizeof(BSFunctions::array_strip_empty($array)));
                
                $array = array('', 'test' => array('', 6));
-               $array = BSFunctions::ArrayStripEmpty($array);
+               $array = BSFunctions::array_strip_empty($array);
                $this->assertEquals(1, sizeof($array));
                $this->assertEquals(1, sizeof($array['test']));
        }
index 01adc6364b29aeba151784b979b01bbe378bb82e..a94d74f46dc5a95a33751da1c75227cc384694c6 100644 (file)
@@ -46,7 +46,8 @@ class InputTest extends PHPUnit_Framework_TestCase
                }*/
                
                require_once ISSO . '/App.php';
-               $this->fixture = BSApp::LoadModule('Input');
+               require_once ISSO . '/Input.php';
+               $this->fixture = new BSInput();
        }
        
        public function testSanitizeInputData()
index 92e06e8593c32e8e32f9d6051f088aa8bb2fe4e5..b6168a201ee17b4407b1e88dca931eda3585affd 100644 (file)
@@ -2,6 +2,7 @@
 
 require_once 'PHPUnit/Framework.php';
 require_once ISSO . '/Installer.php';
+require_once ISSO . '/Input.php';
 
 class InstallerTest extends PHPUnit_Framework_TestCase
 {
@@ -13,7 +14,7 @@ class InstallerTest extends PHPUnit_Framework_TestCase
                global $rig;
                
                $rig = $this;
-               BSApp::Registry()->input = $this->input = BSApp::LoadModule('Input');
+               BSApp::$input = new BSInput();
        }
        
        private function _loadClass()
index 483eac239512ca1d38656dd8a40d57f6154dd929..261fa24a4bd43ae26e77d9e6d4326917202de5ff 100644 (file)
@@ -10,17 +10,19 @@ class TemplateTest extends PHPUnit_Framework_TestCase
        public function setUp()
        {
                require_once ISSO . '/App.php';
+               require_once ISSO . '/Template.php';
                
-               $this->fixture = BSApp::LoadModule('Template');
+               $this->fixture = new BSTemplate();
                $this->fixture->setTemplateDirectory(TEST_TEMPLATE_PATH);
                $this->fixture->setExtension('test.tpl');
                
                if ($this->db == null)
                {
-                       $this->db = BSApp::LoadModule('DbMySql');
+                       require_once ISSO . '/DbMySql.php';
+                       $this->db = new BSDbMySql();
                        $this->db->connect(TEST_DB_MYSQL_HOST, TEST_DB_MYSQL_USER, TEST_DB_MYSQL_PASSWORD, TEST_DB_MYSQL_DATABASE);
                        $this->db->query("CREATE TABLE template (filename VARCHAR (250) NOT NULL, template TEXT NOT NULL, timestamp INT NOT NULL);");
-                       BSApp::Registry()->db = $this->db;
+                       BSApp::$db = $this->db;
                }
        }