diff --git a/t/lib/WebGUI/Test.pm b/t/lib/WebGUI/Test.pm index 98ca63568..1136ed2e3 100644 --- a/t/lib/WebGUI/Test.pm +++ b/t/lib/WebGUI/Test.pm @@ -35,6 +35,7 @@ use Cwd qw[]; use Test::MockObject::Extends; use WebGUI::PseudoRequest; use Scalar::Util qw( blessed ); +use List::MoreUtils qw/ any /; ##Hack to get ALL test output onto STDOUT. use Test::Builder; @@ -52,6 +53,7 @@ my %originalConfig; my $originalSetting; my @groupsToDelete; +my @usersToDelete; my @storagesToDelete; BEGIN { @@ -138,9 +140,14 @@ BEGIN { END { my $Test = Test::Builder->new; - foreach my $group (@groupsToDelete) { + GROUP: foreach my $group (@groupsToDelete) { $group->delete; } + USER: foreach my $user (@usersToDelete) { + my $userId = $user->userId; + next USER if any { $userId eq $_ } (1,3); + $user->delete; + } foreach my $stor (@storagesToDelete) { if ($SESSION->id->valid($stor)) { my $storage = WebGUI::Storage->get($SESSION, $stor); @@ -416,6 +423,22 @@ sub storagesToDelete { #---------------------------------------------------------------------------- +=head2 usersToDelete ( $user, [$user, ...] ) + +Push a list of user objects onto the stack of groups to be automatically deleted +at the end of the test. If found in the stack, the Admin and Visitor users will not be deleted. + +This is a class method. + +=cut + +sub usersToDelete { + my $class = shift; + push @usersToDelete, @_; +} + +#---------------------------------------------------------------------------- + =head1 BUGS When trying to load the APR module, perl invariably throws an Out Of Memory