[pLog-svn] r6659 - plog/branches/lifetype-1.2/class/test/tests/ui

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Mon Jun 23 15:47:37 EDT 2008


Author: jondaley
Date: 2008-06-23 15:47:37 -0400 (Mon, 23 Jun 2008)
New Revision: 6659

Modified:
   plog/branches/lifetype-1.2/class/test/tests/ui/login_test.class.php
Log:
added a new test to test if the user doesn't even have login privileges.  fixed user-doesn't-have-blog-test by giving him the login privilege

Modified: plog/branches/lifetype-1.2/class/test/tests/ui/login_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/ui/login_test.class.php	2008-06-23 18:47:38 UTC (rev 6658)
+++ plog/branches/lifetype-1.2/class/test/tests/ui/login_test.class.php	2008-06-23 19:47:37 UTC (rev 6659)
@@ -2,6 +2,8 @@
 
 	lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
 	lt_include( PLOG_CLASS_PATH."class/test/helpers/testtools.class.php" );	
+    lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/permissions.class.php" );
 	
 	/**
 	 * \ingroup Test
@@ -12,12 +14,33 @@
 		{
 			$this->user = TestTools::createUser();
 			$this->user2 = TestTools::createUser();
-			$this->blog = TestTools::createBlog( $this->user2->getId());
+			$this->user3 = TestTools::createUser();
+
+            $perms = new Permissions();
+            $loginAccess = $perms->getPermissionByName( "login_perm" );
+            if($loginAccess === false){
+				throw( new Exception( "Error getting login permission id" ));
+				die();
+            }
+            $userPerm = new UserPermission( $this->user3->getId(), 0, $loginAccess->getId() );
+            if(!$userPerm){
+				throw( new Exception( "Error creating UserPermission(login)" ));
+				die();
+            }
+
+			$userPerms = new UserPermissions();
+            if(!$userPerms->grantPermission( $userPerm )){
+				throw( new Exception( "Error granting login permissions to user" ));
+				die();
+            }
+                
+            $this->blog = TestTools::createBlog( $this->user2->getId());
 		}
 		
 		function tearDown()
 		{
-			TestTools::deleteDaoTestData( Array( $this->user, $this->user2, $this->blog ));
+			TestTools::deleteDaoTestData( Array( $this->user, $this->user2,
+                                                 $this->user3, $this->blog ));
 		}
 		
 		/**
@@ -38,6 +61,28 @@
 		}
 		
 		/**
+		 * Test that a user without login privileges cannot login
+		 */
+		function testUserDoesntHaveLoginPrivileges()
+		{
+			$this->assertUIScript(
+				Array(
+					"login_page" => Array(
+						"url" => $this->getAdminUrl(),
+						"type" => "post",
+						"params" => Array(
+							"userName" => $this->user->getUserName(),
+							"userPassword" => "password",
+							"op" => "Login"
+						),
+						"expected" => "you are not allowed to log in",
+						"message" => "User was able to login without login privileges!!"
+					)
+				)
+			);			
+		}
+
+        		/**
 		 * Test that a user without a blog cannot login
 		 */
 		function testUserHasNoBlog()
@@ -48,7 +93,7 @@
 						"url" => $this->getAdminUrl(),
 						"type" => "post",
 						"params" => Array(
-							"userName" => $this->user->getUserName(),
+							"userName" => $this->user3->getUserName(),
 							"userPassword" => "password",
 							"op" => "Login"
 						),
@@ -58,7 +103,7 @@
 				)
 			);			
 		}
-		
+
 		/**
 		 * Test the whoe login and logout process
 		 */



More information about the pLog-svn mailing list