[Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[195] trunk/0.4
Status: Beta
Brought to you by:
crazedsanity
From: <cra...@us...> - 2011-01-26 23:06:52
|
Revision: 195 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=195&view=rev Author: crazedsanity Date: 2011-01-26 17:26:38 +0000 (Wed, 26 Jan 2011) Log Message: ----------- All tests work + minor fixes and tweaks. /tests/testOfCSGenericPermissions.php: * __construct() [NEW]: -- explicitely define so parent::__construct() is not called. * setUp(): -- call get_valid_users() only AFTER the permission object is used to create the schema for cs-webapplibs. * tearDown(): -- allow a way to NOT destroy the database after a test. * test_userGroups(): -- commented-out code for keeping a database around -- fixed code for testing creation of user groups (remove a hard-coded value of group ID, instead using a dynamic one). /abstract/cs_genericUserGroup.abstract.class.php: * get_user_groups(): -- also retrieve the "group_admin" field in the query (for later use) Modified Paths: -------------- trunk/0.4/abstract/cs_genericUserGroup.abstract.class.php trunk/0.4/tests/testOfCSGenericPermissions.php Modified: trunk/0.4/abstract/cs_genericUserGroup.abstract.class.php =================================================================== --- trunk/0.4/abstract/cs_genericUserGroup.abstract.class.php 2011-01-26 04:33:58 UTC (rev 194) +++ trunk/0.4/abstract/cs_genericUserGroup.abstract.class.php 2011-01-26 17:26:38 UTC (rev 195) @@ -52,7 +52,7 @@ public function get_user_groups($userId) { if(is_numeric($userId) && $userId >= 0) { try { - $sql = "SELECT ug.*, g.group_name FROM ". self::ugTable ." AS ug INNER " + $sql = "SELECT ug.*, g.group_name, g.group_admin FROM ". self::ugTable ." AS ug INNER " ."JOIN ". parent::groupTable ." as g USING (group_id) WHERE user_id=". $userId; $retval = $this->db->run_query($sql, 'group_id'); } Modified: trunk/0.4/tests/testOfCSGenericPermissions.php =================================================================== --- trunk/0.4/tests/testOfCSGenericPermissions.php 2011-01-26 04:33:58 UTC (rev 194) +++ trunk/0.4/tests/testOfCSGenericPermissions.php 2011-01-26 17:26:38 UTC (rev 195) @@ -13,14 +13,22 @@ class testOfCSGenericPermissions extends testDbAbstract { + //-------------------------------------------------------------------------- + public function __construct() { + }//end __construct() + //-------------------------------------------------------------------------- + + + + //-------------------------------------------------------------------------- function setUp() { $this->gfObj = new cs_globalFunctions; $this->gfObj->debugPrintOpt=1; parent::__construct('postgres','', 'localhost', '5432'); - $this->get_valid_users(); $this->permObj = new _gpTester($this->db); $this->permObj->do_schema(); + $this->get_valid_users(); }//end setUp() //-------------------------------------------------------------------------- @@ -28,7 +36,12 @@ //-------------------------------------------------------------------------- public function tearDown() { - $this->destroy_db(); + if(isset($GLOBALS['keepDb'])) { + unset($GLOBALS['keepDb']); + } + else { + $this->destroy_db(); + } } //-------------------------------------------------------------------------- @@ -54,6 +67,7 @@ //-------------------------------------------------------------------------- public function test_userGroups() { + #$GLOBALS['keepDb'] = true; //make sure there are groups available. { $groupList = $this->permObj->get_all_groups(); @@ -83,9 +97,11 @@ //create & test user_group relationships. { - $newId = $this->permObj->create_user_group($this->validUsers[$myKey]['uid'],1); + $newId = $this->permObj->create_user_group($this->validUsers[$myKey]['uid'],$newGroupId); $this->assertTrue(is_numeric($newId)); - $this->assertTrue($this->permObj->is_group_member($this->validUsers[$myKey]['uid'],1)); + $this->assertTrue($this->permObj->is_group_member($this->validUsers[$myKey]['uid'],$newGroupId), "user (". + $this->validUsers[$myKey]['uid'] .") isn't member of group (". $newGroupId .") after ". + "being added to it... "); $ugList = $this->permObj->get_user_groups($this->validUsers[$myKey]['uid']); $this->assertTrue(is_array($ugList)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |