Provide a way for WebGUI::Test to register groups to clean up at
the end of a test. Convert several tests to use that, including Post.t, which leaked Groups.
This commit is contained in:
parent
0cbe0cc117
commit
ddd06c2ede
4 changed files with 35 additions and 6 deletions
16
t/Group.t
16
t/Group.t
|
|
@ -233,6 +233,7 @@ my $gB = WebGUI::Group->new($session, "new");
|
|||
$gA->name('Group A');
|
||||
$gB->name('Group B');
|
||||
ok( ($gA->name eq 'Group A' and $gB->name eq 'Group B'), 'object name assignment, multiple objects');
|
||||
WebGUI::Test->groupsToDelete($gA, $gB);
|
||||
|
||||
$gB->addGroups([$gA->getId]);
|
||||
|
||||
|
|
@ -253,6 +254,7 @@ cmp_bag($gA->getGroupsIn(), [3], 'Not allowed to add myself to my group');
|
|||
my $gC = WebGUI::Group->new($session, "new");
|
||||
$gC->name('Group C');
|
||||
$gA->addGroups([$gC->getId]);
|
||||
WebGUI::Test->groupsToDelete($gC);
|
||||
|
||||
cmp_bag($gC->getGroupsFor(), [$gA->getId], 'Group A contains Group C');
|
||||
cmp_bag($gA->getGroupsIn(), [$gC->getId, 3], 'Group C is a member of Group A, cached');
|
||||
|
|
@ -279,6 +281,7 @@ my $gZ = WebGUI::Group->new($session, "new");
|
|||
$gX->name('Group X');
|
||||
$gY->name('Group Y');
|
||||
$gZ->name('Group Z');
|
||||
WebGUI::Test->groupsToDelete($gX, $gY, $gZ);
|
||||
|
||||
$gZ->addGroups([$gX->getId, $gY->getId]);
|
||||
|
||||
|
|
@ -439,6 +442,7 @@ ok( isIn($mob[0]->userId, @{ $gZ->getAllUsers() }), 'mob[0] in list of group Z u
|
|||
my $gK = WebGUI::Group->new($session, "new");
|
||||
$gK->name('Group K');
|
||||
$gC->addGroups([$gK->getId]);
|
||||
WebGUI::Test->groupsToDelete($gK);
|
||||
|
||||
# B
|
||||
# / \
|
||||
|
|
@ -498,6 +502,7 @@ $session->setting->set('useKarma', $defaultKarmaSetting);
|
|||
my $gS = WebGUI::Group->new($session, "new");
|
||||
$gS->name('Group S');
|
||||
$gC->addGroups([$gS->getId]);
|
||||
WebGUI::Test->groupsToDelete($gS);
|
||||
|
||||
# B
|
||||
# / \
|
||||
|
|
@ -579,6 +584,7 @@ foreach my $idx (0..$#ipTests) {
|
|||
}
|
||||
|
||||
my $gI = WebGUI::Group->new($session, "new");
|
||||
WebGUI::Test->groupsToDelete($gI);
|
||||
$gI->name('Group I');
|
||||
$gI->ipFilter('194.168.0.0/24');
|
||||
|
||||
|
|
@ -614,6 +620,7 @@ ok( !$cacheDude->isInGroup($gY->getId), "Cache dude removed from group Y");
|
|||
ok( !$cacheDude->isInGroup($gZ->getId), "Cache dude removed from group Z too");
|
||||
|
||||
my $gCache = WebGUI::Group->new($session, "new");
|
||||
WebGUI::Test->groupsToDelete($gCache);
|
||||
|
||||
$gCache->addUsers([$cacheDude->userId]);
|
||||
|
||||
|
|
@ -642,10 +649,13 @@ SKIP: {
|
|||
ok(undef, "expiration date in groupings for getUser");
|
||||
}
|
||||
|
||||
################################################################
|
||||
#
|
||||
# getUserList
|
||||
#
|
||||
################################################################
|
||||
|
||||
END {
|
||||
foreach my $testGroup ($gX, $gY, $gZ, $gA, $gB, $gI, $gC, $g, $gK, $gS, $gCache) {
|
||||
$testGroup->delete if (defined $testGroup and ref $testGroup eq 'WebGUI::Group');
|
||||
}
|
||||
foreach my $dude ($user, @crowd, @mob, @chameleons, @itchies, @tcps, $cacheDude) {
|
||||
$dude->delete if (defined $dude and ref $dude eq 'WebGUI::User');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue