From 8d561101b527cfced0b16a88f4a9bcc946e3b083 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 1 Aug 2008 23:06:23 +0000 Subject: [PATCH] Add a test to User.t to make sure it isn't leaking groups. Update POD in User.pm and Group.pm. --- lib/WebGUI/Group.pm | 3 ++- lib/WebGUI/User.pm | 5 ++++- t/User.t | 18 +++++++++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/WebGUI/Group.pm b/lib/WebGUI/Group.pm index cfa521704..80bc209d0 100755 --- a/lib/WebGUI/Group.pm +++ b/lib/WebGUI/Group.pm @@ -861,7 +861,8 @@ like IP address, LDAP, dbQuery or scratchFilter. =head3 withoutExpired -A boolean that if set true will return the users list minus the expired groupings. +A boolean that if set to true will return only the groups that the user is in where +their membership hasn't expired. =cut diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 5d8843166..c3c26c087 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -189,7 +189,10 @@ sub dateCreated { =head2 delete ( ) -Deletes this user. +Deletes this user, removes their user profile data, cleans up their +inbox, removes userSessionScratch data and authentication information, +removes them from any groups they belong to and deletes their +Friend's group. =cut diff --git a/t/User.t b/t/User.t index 9261e10c2..697eb43ca 100644 --- a/t/User.t +++ b/t/User.t @@ -20,7 +20,7 @@ use WebGUI::Cache; use WebGUI::User; use WebGUI::ProfileField; -use Test::More tests => 129; # increment this value for each test you create +use Test::More tests => 130; # increment this value for each test you create use Test::Deep; my $session = WebGUI::Test->session; @@ -28,7 +28,8 @@ my $session = WebGUI::Test->session; my $testCache = WebGUI::Cache->new($session, 'myTestKey'); $testCache->flush; -my $numberOfUsers = $session->db->quickScalar('select count(*) from users'); +my $numberOfUsers = $session->db->quickScalar('select count(*) from users'); +my $numberOfGroups = $session->db->quickScalar('select count(*) from groups'); my $user; my $lastUpdate; @@ -556,6 +557,12 @@ $friend->deleteFromGroups([$neighbor->friends->getId]); $neighbor->profileField('allowPrivateMessages', 'not a valid choice'); is ($neighbor->acceptsPrivateMessages($friend->userId), 1, 'acceptsPrivateMessages: illegal profile field allows messages to be received from anyone'); +################################################################ +# +# getGroupIdsRecursive +# +################################################################ + END { foreach my $account ($user, $dude, $buster, $buster3, $neighbor, $friend) { (defined $account and ref $account eq 'WebGUI::User') and $account->delete; @@ -574,8 +581,9 @@ END { $newProfileField->delete(); $testCache->flush; - my $newNumberOfUsers = $session->db->quickScalar('select count(*) from users'); - is ($newNumberOfUsers, $numberOfUsers, 'no new additional users were leaked by this test'); - + my $newNumberOfUsers = $session->db->quickScalar('select count(*) from users'); + my $newNumberOfGroups = $session->db->quickScalar('select count(*) from groups'); + is ($newNumberOfUsers, $numberOfUsers, 'no new additional users were leaked by this test'); + is ($newNumberOfGroups, $numberOfGroups, 'no new additional groups were leaked by this test'); }