Group test for user expiration inside a group.
1 POD tweak, more placeholder work.
This commit is contained in:
parent
5ee17a673f
commit
0eb6ec7b01
2 changed files with 14 additions and 15 deletions
|
|
@ -229,9 +229,9 @@ Deletes this group and all references to it.
|
|||
|
||||
sub delete {
|
||||
my $self = shift;
|
||||
$self->session->db->write("delete from groups where groupId=".$self->session->db->quote($self->getId));
|
||||
$self->session->db->write("delete from groupings where groupId=".$self->session->db->quote($self->getId));
|
||||
$self->session->db->write("delete from groupGroupings where inGroup=".$self->session->db->quote($self->getId)." or groupId=".$self->session->db->quote($self->getId));
|
||||
$self->session->db->write("delete from groups where groupId=?", [$self->getId]);
|
||||
$self->session->db->write("delete from groupings where groupId=?", [$self->getId]);
|
||||
$self->session->db->write("delete from groupGroupings where inGroup=? or groupId=?", [$self->getId, $self->getId]);
|
||||
undef $self;
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +279,7 @@ sub deleteUsers {
|
|||
my $users = shift;
|
||||
$self->session->stow->delete("isInGroup");
|
||||
foreach my $uid (@{$users}) {
|
||||
$self->session->db->write("delete from groupings where groupId=".$self->session->db->quote($self->getId)." and userId=".$self->session->db->quote($uid));
|
||||
$self->session->db->write("delete from groupings where groupId=? and userId=?",[$self->getId, $uid]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -966,7 +966,7 @@ sub userIsAdmin {
|
|||
|
||||
=head2 userGroupExpireDate ( userId [, epoch ] )
|
||||
|
||||
Returns the epoch date that this grouping will expire.
|
||||
Returns the epoch date that this grouping will expire for a particular user.
|
||||
|
||||
=head3 userId
|
||||
|
||||
|
|
@ -983,15 +983,12 @@ sub userGroupExpireDate {
|
|||
my $userId = shift;
|
||||
my $epoch = shift;
|
||||
if ($epoch) {
|
||||
$self->session->db->write("update groupings set expireDate=".$self->session->db->quote($epoch)." where groupId=".$self->session->db->quote($self->getId)." and userId=".$self->session->db->quote($userId));
|
||||
$self->session->db->write("update groupings set expireDate=? where groupId=? and userId=?",[$epoch, $self->getId, $userId]);
|
||||
return $epoch;
|
||||
} else {
|
||||
my ($expireDate) = $self->session->db->quickArray("select expireDate from groupings where groupId=".$self->session->db->quote($self->getId)." and userId=".$self->session->db->quote($userId));
|
||||
my ($expireDate) = $self->session->db->quickArray("select expireDate from groupings where groupId=? and userId=?", [$self->getId, $userId]);
|
||||
return $expireDate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
12
t/Group.t
12
t/Group.t
|
|
@ -18,7 +18,7 @@ use WebGUI::Utility;
|
|||
|
||||
use WebGUI::User;
|
||||
use WebGUI::Group;
|
||||
use Test::More tests => 50; # increment this value for each test you create
|
||||
use Test::More tests => 51; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
|
@ -140,10 +140,6 @@ cmp_bag($gB->getGroupsIn(1), [$gA->getId, $gC->getId, $gZ->getId, $gY->getId, $g
|
|||
$gX->addGroups([$gA->getId]);
|
||||
cmp_bag($gX->getGroupsIn(), [3], 'Not able to add B tree under Z tree under X');
|
||||
|
||||
#$gX->userIsAdmin(1, "yes");
|
||||
|
||||
#ok(!$gX->userIsAdmin(1), "userIsAdmin: Visitor is not allowed to be a Group Admin");
|
||||
|
||||
my $user = WebGUI::User->new($session, "new");
|
||||
$gX->userIsAdmin($user->userId, "yes");
|
||||
ok(!$gX->userIsAdmin($user->userId), "userIsAdmin: User who isn't secondary admin can't be group admin");
|
||||
|
|
@ -154,12 +150,18 @@ ok($user->isInGroup(12), "userIsAdmin: Added dude to Secondary Admins");
|
|||
$gX->userIsAdmin($user->userId, 1);
|
||||
ok(!$gX->userIsAdmin($user->userId), "userIsAdmin: User must be member of group to be group admin");
|
||||
|
||||
my $addedUserTime = time();
|
||||
$user->addToGroups([$gX->getId]);
|
||||
ok($user->isInGroup($gX->getId), "userIsAdmin: Added dude to gX");
|
||||
|
||||
$gX->userIsAdmin($user->userId, 1);
|
||||
ok($gX->userIsAdmin($user->userId), "userIsAdmin: Dude set to be group admin for gX");
|
||||
|
||||
my $expireOffset = $gX->expireOffset;
|
||||
my $expireTime = $addedUserTime+$expireOffset;
|
||||
|
||||
ok( abs($gX->userGroupExpireDate($user->userId) - $expireTime) < 1, 'userGroupExpireDate: Default expire time');
|
||||
|
||||
$user->delete;
|
||||
|
||||
END {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue