From d93238d53c6ac43bb335c57a3882a0bfaaf0fbaa Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 5 Oct 2010 11:30:17 -0700 Subject: [PATCH] Move Auth cleanup into a addToCleanup sub. --- t/Auth.t | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/t/Auth.t b/t/Auth.t index 571011797..cc328589a 100644 --- a/t/Auth.t +++ b/t/Auth.t @@ -49,6 +49,25 @@ $auth = WebGUI::Auth->new( $session, $AUTH_METHOD ); my $username = $session->id->generate; push @cleanupUsernames, $username; $output = $auth->createAccountSave( $username, { }, "PASSWORD" ); +WebGUI::Test->addToCleanup(sub { + for my $username ( @cleanupUsernames ) { + # We don't create actual, real users, so we have to cleanup by hand + my $userId = $session->db->quickScalar( + "SELECT userId FROM users WHERE username=?", + [ $username ] + ); + + my @tableList + = qw{authentication users userProfileData groupings inbox userLoginLog}; + + for my $table ( @tableList ) { + $session->db->write( + "DELETE FROM $table WHERE userId=?", + [ $userId ] + ); + } + } +}); is( $session->http->getRedirectLocation, 'REDIRECT_URL', @@ -83,25 +102,3 @@ is $output, undef, 'login returns undef when showMessageOnLogin is false'; # Session Cleanup $session->{_request} = $oldRequest; - -#---------------------------------------------------------------------------- -# Cleanup -END { - for my $username ( @cleanupUsernames ) { - # We don't create actual, real users, so we have to cleanup by hand - my $userId = $session->db->quickScalar( - "SELECT userId FROM users WHERE username=?", - [ $username ] - ); - - my @tableList - = qw{authentication users userProfileData groupings inbox userLoginLog}; - - for my $table ( @tableList ) { - $session->db->write( - "DELETE FROM $table WHERE userId=?", - [ $userId ] - ); - } - } -}