diff --git a/t/lib/WebGUI/Test.pm b/t/lib/WebGUI/Test.pm index 6f18bacd6..75ee57659 100644 --- a/t/lib/WebGUI/Test.pm +++ b/t/lib/WebGUI/Test.pm @@ -2,6 +2,7 @@ package WebGUI::Test; use strict; use warnings; +use Storable qw/dclone/; =head1 LEGAL @@ -47,6 +48,8 @@ our $logger_debug; our $logger_info; our $logger_error; +my %originalConfig = (); + BEGIN { STDERR->autoflush(1); @@ -135,6 +138,14 @@ END { $Test->diag('Users : '.$SESSION->db->quickScalar('select count(*) from users')); $Test->diag('Groups : '.$SESSION->db->quickScalar('select count(*) from groups')); } + while (my ($key, $value) = each %originalConfig) { + if (defined $value) { + $SESSION->config->set($key, $value); + } + else { + $SESSION->config->delete($key); + } + } $SESSION->var->end; $SESSION->close if defined $SESSION; } @@ -332,6 +343,24 @@ sub session { } +#---------------------------------------------------------------------------- + +=head2 originalConfig ( $param ) + +Stores the original data from the config file, to be restored +automatically at the end of the test. This is a class method. + +=cut + +sub originalConfig { + my ($class, $param) = @_; + my $safeValue = my $value = $SESSION->config->get($param); + if (ref $value) { + $safeValue = dclone $value; + } + $originalConfig{$param} = $safeValue; +} + #---------------------------------------------------------------------------- =head1 BUGS