[pLog-svn] r4554 - in plog/branches/lifetype-1.1.5/class: dao dao/userdata test/tests/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Wed Jan 17 21:46:56 GMT 2007


Author: oscar
Date: 2007-01-17 21:46:55 +0000 (Wed, 17 Jan 2007)
New Revision: 4554

Added:
   plog/branches/lifetype-1.1.5/class/test/tests/dao/userinfo_test.class.php
Modified:
   plog/branches/lifetype-1.1.5/class/dao/userdata/baseuserdataprovider.class.php
   plog/branches/lifetype-1.1.5/class/dao/userinfo.class.php
Log:
Fixed mantis issue http://bugs.lifetype.net/view.php?id=1139 as per Jon's suggestions (user confirmed that the fix worked -- I was never able to reproduce it) I've also added a test case that while not very conclusive, is better than nothing :)


Modified: plog/branches/lifetype-1.1.5/class/dao/userdata/baseuserdataprovider.class.php
===================================================================
--- plog/branches/lifetype-1.1.5/class/dao/userdata/baseuserdataprovider.class.php	2007-01-17 21:39:05 UTC (rev 4553)
+++ plog/branches/lifetype-1.1.5/class/dao/userdata/baseuserdataprovider.class.php	2007-01-17 21:46:55 UTC (rev 4554)
@@ -154,7 +154,7 @@
                                       $query_result["id"]);
                                                                             
             // set some permissions
-			isset( $query_result["site_admin"] ) ? $siteAdmin = $query_result["site_admin"] : $siteAdmin = false;
+			isset( $query_result["site_admin"] ) ? $siteAdmin = $query_result["site_admin"] : $siteAdmin = 0;
             $userInfo->setSiteAdmin( $siteAdmin );
             $userInfo->setStatus( $query_result["status"] );
 

Modified: plog/branches/lifetype-1.1.5/class/dao/userinfo.class.php
===================================================================
--- plog/branches/lifetype-1.1.5/class/dao/userinfo.class.php	2007-01-17 21:39:05 UTC (rev 4553)
+++ plog/branches/lifetype-1.1.5/class/dao/userinfo.class.php	2007-01-17 21:46:55 UTC (rev 4554)
@@ -51,7 +51,7 @@
 			$this->_email = $email;
 			$this->_blogs = "";
 			$this->_fullName = $fullName;
-            $this->_siteAdmin = false;
+            $this->_siteAdmin = 0;
 			$this->setPictureId( $resourcePictureId );
 			$this->setProperties( $properties );
 			
@@ -191,7 +191,7 @@
 
         function isSiteAdmin()
         {
-			if( $this->_siteAdmin == "" ) $this->_siteAdmin = false;
+			if( $this->_siteAdmin == "" ) $this->_siteAdmin = 0;
         	return $this->_siteAdmin;
         }
 

Added: plog/branches/lifetype-1.1.5/class/test/tests/dao/userinfo_test.class.php
===================================================================
--- plog/branches/lifetype-1.1.5/class/test/tests/dao/userinfo_test.class.php	2007-01-17 21:39:05 UTC (rev 4553)
+++ plog/branches/lifetype-1.1.5/class/test/tests/dao/userinfo_test.class.php	2007-01-17 21:46:55 UTC (rev 4554)
@@ -0,0 +1,37 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
+	include_once( PLOG_CLASS_PATH."class/test/helpers/testtools.class.php" );	
+	include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
+	include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );	
+
+	class UserInfo_Test extends LifeTypeTestCase
+	{
+		/**
+		 * Test case for Mantis issue 1139 (http://bugs.lifetype.net/view.php?id=1139):
+		 * "confirmation code is invalid"
+		 *
+		 * This test case will make sure that empty values of UserInfo::_siteAdmin() will always be loaded
+		 * and mapped to '0' when saving to the database. It should also check that when 'false' is used
+		 * in addition to '0' for this attribute, the class behaves in exactly the same way
+		 */
+		function testConfirmationCodeIsInvalid()
+		{
+			// user1, let's not set the isSiteAdmin flag and check that we return a zero and a false
+			$user1 = new UserInfo( md5(rand()), "user1pwd", "user1 at test.com", "", "User One" );
+			$this->assertEquals( 0, $user1->isSiteAdmin(), "UserInfo::isSiteAdmin() did not return zero!" );
+			$this->assertFalse( $user1->isSiteAdmin(), "UserInfo::isSiteAdmin() did not return false!" );
+			
+			// save this user to the database and make sure that the flag was saved as expected
+			$users = new Users();
+			$users->addUser( $user1 );
+			// load the user
+			$newUser1 = $users->getUserInfoFromId( $user1->getId());
+			$this->assertEquals( 0, $newUser1->isSiteAdmin(), "UserInfo::isSiteAdmin() did not return zero after saving the user!" );
+			$this->assertFalse( $newUser1->isSiteAdmin(), "UserInfo::isSiteAdmin() did not return false after saving the user!" );		
+		
+			// delete the test data
+			TestTools::deleteDaoTestData( Array( $user1 ));
+		}
+	}
+?>
\ No newline at end of file



More information about the pLog-svn mailing list