From d7f2aca1e4e68e377548339a019643522d04389f Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 30 Apr 2009 23:57:39 +0000 Subject: [PATCH] Test clean-up for users and groups in Shop/Vendor and all Macro tests. --- t/Macro/GroupText.t | 9 +++------ t/Macro/User.t | 4 +--- t/Macro/UsersOnline.t | 2 +- t/Shop/Vendor.t | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/t/Macro/GroupText.t b/t/Macro/GroupText.t index fa9d701d3..c3f066066 100644 --- a/t/Macro/GroupText.t +++ b/t/Macro/GroupText.t @@ -65,12 +65,14 @@ my $sth = $session->db->prepare('INSERT INTO myUserTable VALUES(?)'); foreach my $mob (@mob) { $sth->execute([ $mob->userId ]); } +WebGUI::Test->usersToDelete(@mob); ##Create the 3 groups $ms_users = WebGUI::Group->new($session, "new"); $ms_distributors = WebGUI::Group->new($session, "new"); $ms_int_distributors = WebGUI::Group->new($session, "new"); +WebGUI::Test->groupsToDelete($ms_users, $ms_distributors, $ms_int_distributors); $ms_users->name('MS Users'); $ms_distributors->name('MS Distributors'); @@ -92,6 +94,7 @@ $ms_distributors->addGroups([$ms_int_distributors->getId]); $disti = WebGUI::User->new($session, 'new'); $int_disti = WebGUI::User->new($session, 'new'); +WebGUI::Test->usersToDelete($disti, $int_disti); $ms_distributors->addUsers([$disti->userId]); $ms_int_distributors->addUsers([$int_disti->userId]); @@ -124,11 +127,5 @@ is($output, 'user,disti,int_disti', 'user is in all three groups'); ##clean up everything END { - foreach my $testGroup ($ms_users, $ms_distributors, $ms_int_distributors, ) { - $testGroup->delete if (defined $testGroup and ref $testGroup eq 'WebGUI::Group'); - } - foreach my $dude (@mob, $disti, $int_disti, ) { - $dude->delete if (defined $dude and ref $dude eq 'WebGUI::User'); - } $session->db->dbh->do('DROP TABLE IF EXISTS myUserTable'); } diff --git a/t/Macro/User.t b/t/Macro/User.t index 73003f884..6053a1955 100644 --- a/t/Macro/User.t +++ b/t/Macro/User.t @@ -51,6 +51,7 @@ plan tests => $numTests; @testSets = setupTest($session, @testSets); my @users = map { $_->{user} } @testSets; +WebGUI::Test->usersToDelete(@users); foreach my $testSet (@testSets) { $session->user({ userId => $testSet->{user}->userId }); @@ -80,7 +81,4 @@ sub setupTest { } END { ##Clean-up after yourself, always - foreach my $dude (@users) { - $dude->delete if (defined $dude and ref $dude eq 'WebGUI::User'); - } } diff --git a/t/Macro/UsersOnline.t b/t/Macro/UsersOnline.t index 089699c23..42734ec33 100644 --- a/t/Macro/UsersOnline.t +++ b/t/Macro/UsersOnline.t @@ -192,6 +192,7 @@ sub setupUsers { my $newSession = WebGUI::Session->open(WebGUI::Test::root, WebGUI::Test::file); $newSession->user({user => $_}); } + WebGUI::Test->usersToDelete(@users); return @users; } @@ -251,5 +252,4 @@ EOTMPL END { ##Clean-up after yourself, always $template->purge; - $_->delete foreach (@users); } diff --git a/t/Shop/Vendor.t b/t/Shop/Vendor.t index f00533eab..d7ca2f4e6 100644 --- a/t/Shop/Vendor.t +++ b/t/Shop/Vendor.t @@ -45,6 +45,7 @@ my $fenceUser = WebGUI::User->new($session, 'new'); $fenceUser->username('fence'); my $guardUser = WebGUI::User->new($session, 'new'); $guardUser->username('guard'); +WebGUI::Test->usersToDelete($fenceUser, $guardUser); SKIP: { @@ -312,7 +313,5 @@ undef $guard; # Cleanup END { $fence->delete; - $fenceUser->delete; - $guardUser->delete; is( scalar @{ WebGUI::Shop::Vendor->getVendors($session) }, $numberOfVendors, 'No vendors leaked'); }