Index: trunk/tests/AppTest.php
===================================================================
--- trunk/tests/AppTest.php	(revision 88)
+++ trunk/tests/AppTest.php	(revision 136)
@@ -32,5 +32,5 @@
     function test_getinstance()
     {
-        $thisapp =& App::getinstance();
+        $thisapp =& App::getInstance();
         $this->assertTrue(serialize($thisapp) == serialize($this->App), 'Objects do not match across instantiations.');
     }
@@ -71,5 +71,7 @@
     function test_dbquery()
     {
-        $qid = DB::query("SELECT 2 + 2");
+		$db =& DB::getInstance();
+	
+        $qid = $db->query("SELECT 2 + 2");
         list($result) = mysql_fetch_row($qid);
         $this->assertEquals('4', $result);
@@ -78,7 +80,8 @@
     function test_raisemsg()
     {
+        $app =& App::getInstance();
         $expected = 'My message';
-        App::raiseMsg($expected, MSG_NOTICE, __FILE__, __LINE__);
-        $msg = current($_SESSION[$this->App->app]['messages']);
+        $app->raiseMsg($expected, MSG_NOTICE, __FILE__, __LINE__);
+        $msg = current($_SESSION[$this->App->_ns]['messages']);
         $this->assertEquals($expected, $msg['message']);
     }
@@ -87,5 +90,6 @@
     {
         ob_start();
-        App::printraisedmessages();
+        $app =& App::getInstance();
+        $app->printraisedmessages();
         $result = ob_get_clean();
         $this->assertContains('My message', $result, 'Raised message not found in output.');
@@ -94,6 +98,7 @@
     function test_logmsg()
     {
+        $app =& App::getInstance();
         $file = $this->App->getParam('log_directory') . '/' . $this->App->getParam('log_filename');
-        App::logMsg('Test log message', LOG_DEBUG, __FILE__, __LINE__);
+        $app->logMsg('Test log message', LOG_DEBUG, __FILE__, __LINE__);
         if ($result = file($file)) {
             $result = end($result);
@@ -106,6 +111,7 @@
     function test_ohref()
     {
+        $app =& App::getInstance();
         $_GET['arg1'] = 'A';
-        $result = App::ohref('/some/url.php', array('arg1'), true);
+        $result = $app->ohref('/some/url.php', array('arg1'), true);
         $this->assertContains(session_name(), $result, 'SSID not found in URL.');
         $this->assertContains('arg1=A', $result, 'Argument not passed through.');
@@ -114,6 +120,7 @@
     function test_printhiddensession()
     {
+        $app =& App::getInstance();
         ob_start();
-        App::printhiddensession();
+        $app->printhiddensession();
         $result = ob_get_clean();
         $this->assertContains(session_name(), $result);
@@ -122,5 +129,6 @@
 //     function test_dieurl()
 //     {
-//         App::dieURL('/die/to/this/url.php');
+//         $app =& App::getInstance();
+//         $app->dieURL('/die/to/this/url.php');
 //     }
 //
Index: trunk/tests/Auth_FileTest.php
===================================================================
--- trunk/tests/Auth_FileTest.php	(revision 88)
+++ trunk/tests/Auth_FileTest.php	(revision 136)
@@ -23,5 +23,6 @@
         require dirname(__FILE__) . '/_config.inc.php';
         require_once '../lib/Auth_File.inc.php';
-        $this->Auth_File =& new Auth_File(array('htpasswd_file' => dirname(__FILE__) . '/_test_htpasswd'));
+        $this->Auth_File =& new Auth_File('test_auth');
+        $this->Auth_File->setParam(array('htpasswd_file' => dirname(__FILE__) . '/_test_htpasswd'));
     }
 
@@ -44,5 +45,5 @@
         $result = $this->Auth_File->login('testuser', 'testpass');
         $this->assertTrue($result, 'testuser login failed.');
-        $this->assertTrue($_SESSION['_auth']['authenticated'], 'testuser authentication not found in session.');
+        $this->assertTrue($_SESSION[$this->Auth_File->_ns]['authenticated'], 'testuser authentication not found in session.');
     }
 
@@ -51,5 +52,5 @@
         $result = $this->Auth_File->login('testuser', 'testpass');
         $this->Auth_File->clearauth();
-        $this->assertFalse($_SESSION['_auth']['authenticated'], 'testuser authentication not false in session.');
+        $this->assertFalse($_SESSION[$this->Auth_File->_ns]['authenticated'], 'testuser authentication not false in session.');
     }
 
Index: trunk/tests/Auth_SQLTest.php
===================================================================
--- trunk/tests/Auth_SQLTest.php	(revision 88)
+++ trunk/tests/Auth_SQLTest.php	(revision 136)
@@ -21,5 +21,5 @@
     function setUp()
     {
-        require dirname(__FILE__) . '/_config.inc.php';
+	    require dirname(__FILE__) . '/_config.inc.php';
         require_once '../lib/Auth_SQL.inc.php';
         $this->Auth_SQL =& new Auth_SQL('testauth');
@@ -29,5 +29,6 @@
             'db_login_table'    => 'test_login_tbl',
             'login_url'         => '/login.php',
-            'blocking'          => true
+            'blocking'          => true,
+            'encryption_type' => AUTH_ENCRYPT_MD5_HARDENED,
         ));
 
@@ -36,5 +37,6 @@
 
         // Insert test data.
-        DB::query("
+        $db =& DB::getInstance();
+        $db->query("
             INSERT INTO test_user_tbl (
                 username,
@@ -46,5 +48,5 @@
             ) VALUES (
                 'testuser',
-                md5('testpass'),
+                '" . $this->Auth_SQL->encryptPassword('testpass') . "',
                 'John',
                 'Doe',
@@ -58,7 +60,9 @@
     function tearDown()
     {
-        unset($this->Auth_SQL);
-        DB::query("DROP TABLE IF EXISTS test_user_tbl");
-        DB::query("DROP TABLE IF EXISTS test_login_tbl");
+    	$db =& DB::getInstance();
+	
+	    unset($this->Auth_SQL);
+        $db->query("DROP TABLE IF EXISTS test_user_tbl");
+        $db->query("DROP TABLE IF EXISTS test_login_tbl");
     }
 
@@ -66,10 +70,10 @@
     {
         $this->Auth_SQL->setval('testuserkey', 'testuserval');
-        $this->assertEquals('testuserval', $_SESSION[$this->Auth_SQL->_sess]['user_data']['testuserkey']);
+        $this->assertEquals('testuserval', $_SESSION[$this->Auth_SQL->_ns]['user_data']['testuserkey']);
     }
 
     function test_getval()
     {
-        $_SESSION[$this->Auth_SQL->_sess]['user_data']['testuserkey'] = 'testuserval';
+        $_SESSION[$this->Auth_SQL->_ns]['user_data']['testuserkey'] = 'testuserval';
         $val = $this->Auth_SQL->getVal('testuserkey');
         $this->assertEquals('testuserval', $val);
@@ -107,5 +111,5 @@
         $this->assertTrue($true, 'User login failed, but should have succeeded.');
 
-        echo "Testing wrong password...\n";
+        // Testing wrong password.
         $false = $this->Auth_SQL->authenticate('testuser', 'wrongpass');
 
@@ -122,6 +126,6 @@
         $after_logged_in = $this->Auth_SQL->isloggedin();
         $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.');
-
-        echo "Testing wrong password...\n";
+        
+        // Testing wrong password.
         $login2 = $this->Auth_SQL->login('testuser', 'wrongpass');
         $this->assertFalse($login2, '4. User login succeeded, but should have failed.');
@@ -140,7 +144,9 @@
     function test_blockaccount()
     {
+		$db =& DB::getInstance();
+	
         $this->Auth_SQL->login('testuser', 'testpass');
         $this->Auth_SQL->blockaccount(null, 'blocktestuser');
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT blocked_reason
             FROM test_user_tbl
@@ -152,10 +158,12 @@
     function test_unblockaccount()
     {
-        DB::query("
+		$db =& DB::getInstance();
+	
+        $db->query("
             UPDATE test_user_tbl SET blocked_reason = 'blocktestuser'
         ");
         $this->Auth_SQL->unblockaccount();
 
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT blocked_reason
             FROM test_user_tbl
@@ -185,17 +193,41 @@
     function test_encryptpassword()
     {
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_MD5));
         $result = $this->Auth_SQL->encryptpassword('123');
         $this->assertEquals('202cb962ac59075b964b07152d234b70', $result);
+
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_MD5_HARDENED));
+        $result = $this->Auth_SQL->encryptpassword('123');
+        $this->assertEquals('c55e4ac608a8768ecd758fab971b0646', $result);
+
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1));
+        $result = $this->Auth_SQL->encryptpassword('123');
+        $this->assertEquals('40bd001563085fc35165329ea1ff5c5ecbdbbeef', $result);
+
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED));
+        $result = $this->Auth_SQL->encryptpassword('123');
+        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $result);
+
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_PLAINTEXT));
+        $result = $this->Auth_SQL->encryptpassword('123');
+        $this->assertEquals('123', $result);
+
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_CRYPT));
+        $result = $this->Auth_SQL->encryptpassword('123', 'saltstring');
+        $this->assertEquals('saEZ6MlWYV9nQ', $result);
     }
 
     function test_setpassword()
     {
+		$db =& DB::getInstance();
+	
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED));
         $this->Auth_SQL->setpassword(null, '123');
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT userpass
             FROM test_user_tbl
         ");
         list($pass) = mysql_fetch_row($qid);
-        $this->assertEquals('202cb962ac59075b964b07152d234b70', $pass);
+        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $pass);
     }
 
Index: trunk/tests/DBSessionHandlerTest.php
===================================================================
--- trunk/tests/DBSessionHandlerTest.php	(revision 88)
+++ trunk/tests/DBSessionHandlerTest.php	(revision 136)
@@ -24,13 +24,7 @@
         require_once '../lib/DBSessionHandler.inc.php';
         session_write_close();
-        $this->DBSessionHandler = new DBSessionHandler($app->db);
-        $this->DBSessionHandler = new DBSessionHandler(null, array(
-            'db_server' => $app->getParam('db_server'),
-            'db_name' => $app->getParam('db_name'),
-            'db_user' => $app->getParam('db_user'),
-            'db_pass' => $app->getParam('db_pass'),
-            'db_always_debug' => $app->getParam('db_always_debug'),
-            'db_debug' => $app->getParam('db_debug'),
-            'db_die_on_failure' => $app->getParam('db_die_on_failure'),
+        $this->DBSessionHandler = new DBSessionHandler($app->db, array(
+            'db_table' => 'session_tbl',
+            'create_table' => true,
         ));
     }
Index: trunk/tests/RecordLockTest.php
===================================================================
--- trunk/tests/RecordLockTest.php	(revision 88)
+++ trunk/tests/RecordLockTest.php	(revision 136)
@@ -21,10 +21,10 @@
 
     function setUp()
-    {
+    {	
         require dirname(__FILE__) . '/_config.inc.php';
         require_once '../lib/RecordLock.inc.php';
         require_once '../lib/Auth_SQL.inc.php';
 
-        $this->Auth_SQL =& new Auth_SQL('testauth');
+        $this->Auth_SQL =& new Auth_SQL('test');
         $this->Auth_SQL->setParam(array(
             'db_table'          => 'test_user_tbl',
@@ -39,5 +39,6 @@
 
         // Insert test data.
-        DB::query("
+        $db =& DB::getInstance();
+        $db->query("
             INSERT INTO test_user_tbl (
                 username,
@@ -49,5 +50,5 @@
             ) VALUES (
                 'testuser',
-                md5('testpass'),
+                '" . $this->Auth_SQL->encryptPassword('testpass') . "',
                 'John',
                 'Doe',
@@ -57,4 +58,8 @@
         ");
         $this->Auth_SQL->login('testuser', 'testpass');
+
+        if (!$this->Auth_SQL->isLoggedIn()) {
+            trigger_error("User login failed...tests canceled.", E_USER_ERROR);
+        }
 
         $this->RecordLock =& RecordLock::getInstance($this->Auth_SQL);
@@ -67,9 +72,11 @@
     function tearDown()
     {
+		$db =& DB::getInstance();
+	
         unset($this->RecordLock);
         unset($this->Auth_SQL);
-        DB::query("DROP TABLE IF EXISTS test_user_tbl");
-        DB::query("DROP TABLE IF EXISTS test_login_tbl");
-        DB::query("DROP TABLE IF EXISTS test_lock_tbl");
+        $db->query("DROP TABLE IF EXISTS test_user_tbl");
+        $db->query("DROP TABLE IF EXISTS test_login_tbl");
+        $db->query("DROP TABLE IF EXISTS test_lock_tbl");
     }
 
Index: trunk/tests/RecordVersionTest.php
===================================================================
--- trunk/tests/RecordVersionTest.php	(revision 88)
+++ trunk/tests/RecordVersionTest.php	(revision 136)
@@ -21,5 +21,5 @@
 
     function setUp()
-    {
+    {	
         require dirname(__FILE__) . '/_config.inc.php';
         require_once '../lib/RecordVersion.inc.php';
@@ -39,5 +39,6 @@
 
         // Insert test data.
-        DB::query("
+        $db =& DB::getInstance();
+        $db->query("
             INSERT INTO test_user_tbl (
                 username,
@@ -68,9 +69,11 @@
     function tearDown()
     {
+		$db =& DB::getInstance();
+	
         unset($this->RecordVersion);
         unset($this->Auth_SQL);
-        DB::query("DROP TABLE IF EXISTS test_user_tbl");
-        DB::query("DROP TABLE IF EXISTS test_login_tbl");
-        DB::query("DROP TABLE IF EXISTS test_version_tbl");
+        $db->query("DROP TABLE IF EXISTS test_user_tbl");
+        $db->query("DROP TABLE IF EXISTS test_login_tbl");
+        $db->query("DROP TABLE IF EXISTS test_version_tbl");
     }
 
Index: trunk/tests/SessionCacheTest.php
===================================================================
--- trunk/tests/SessionCacheTest.php	(revision 88)
+++ trunk/tests/SessionCacheTest.php	(revision 136)
@@ -4,5 +4,5 @@
 
 /**
- * PHPUnit test case for SessionCache
+ * PHPUnit test case for Cache
  *
  * The method skeletons below need to be filled in with
@@ -13,9 +13,9 @@
  */
 require_once 'PHPUnit.php';
-class SessionCacheTest extends PHPUnit_TestCase {
+class CacheTest extends PHPUnit_TestCase {
 
-    var $SessionCache;
+    var $Cache;
 
-    function SessionCacheTest($name)
+    function CacheTest($name)
     {
         $this->PHPUnit_TestCase($name);
@@ -25,16 +25,16 @@
     {
         require dirname(__FILE__) . '/_config.inc.php';
-        require_once '../lib/SessionCache.inc.php';
-        $this->SessionCache =& new SessionCache(PARAM);
+        require_once '../lib/Cache.inc.php';
+        $this->Cache =& new Cache(PARAM);
     }
 
     function tearDown()
     {
-        unset($this->SessionCache);
+        unset($this->Cache);
     }
 
     function test_getinstance()
     {
-        $result = $this->SessionCache->getinstance(PARAM);
+        $result = $this->Cache->getinstance(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -43,5 +43,5 @@
     function test_setparam()
     {
-        $result = $this->SessionCache->setparam(PARAM);
+        $result = $this->Cache->setparam(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -50,5 +50,5 @@
     function test_getparam()
     {
-        $result = $this->SessionCache->getparam(PARAM);
+        $result = $this->Cache->getparam(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -57,5 +57,5 @@
     function test_putcache()
     {
-        $result = $this->SessionCache->putcache(PARAM);
+        $result = $this->Cache->putcache(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -64,5 +64,5 @@
     function test_getcache()
     {
-        $result = $this->SessionCache->getcache(PARAM);
+        $result = $this->Cache->getcache(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -71,5 +71,5 @@
     function test_iscached()
     {
-        $result = $this->SessionCache->iscached(PARAM);
+        $result = $this->Cache->iscached(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -78,5 +78,5 @@
     function test_breakcache()
     {
-        $result = $this->SessionCache->breakcache(PARAM);
+        $result = $this->Cache->breakcache(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -85,5 +85,5 @@
 }
 // Running the test.
-$suite = new PHPUnit_TestSuite('SessionCacheTest');
+$suite = new PHPUnit_TestSuite('CacheTest');
 $result = PHPUnit::run($suite);
 echo $result->toString();
Index: trunk/tests/_config.inc.php
===================================================================
--- trunk/tests/_config.inc.php	(revision 88)
+++ trunk/tests/_config.inc.php	(revision 136)
@@ -1,5 +1,5 @@
 <?php
 require_once '../lib/App.inc.php';
-$app =& App::getinstance('testapp');
+$app =& App::getInstance('testapp');
 
 $app->setParam(array(
