Add an autoclean-up method to WebGUI::Test, and convert the Story test
to use it.
This commit is contained in:
parent
1edaca4ed2
commit
314a12def2
2 changed files with 32 additions and 4 deletions
|
|
@ -53,6 +53,9 @@ $archiveTag->commit;
|
||||||
|
|
||||||
my $storage1 = WebGUI::Storage->create($session);
|
my $storage1 = WebGUI::Storage->create($session);
|
||||||
my $storage2 = WebGUI::Storage->create($session);
|
my $storage2 = WebGUI::Storage->create($session);
|
||||||
|
WebGUI::Test->storagesToDelete($storage1, $storage2);
|
||||||
|
diag $storage1->getId;
|
||||||
|
diag $session->id->toHex($storage1->getId);
|
||||||
|
|
||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
|
|
@ -359,8 +362,7 @@ cmp_deeply(
|
||||||
isnt($newPhotoData->[0]->{storageId}, $photoData->[0]->{storageId}, '... and storage 0 is duplicated');
|
isnt($newPhotoData->[0]->{storageId}, $photoData->[0]->{storageId}, '... and storage 0 is duplicated');
|
||||||
isnt($newPhotoData->[1]->{storageId}, $photoData->[1]->{storageId}, '... and storage 1 is duplicated');
|
isnt($newPhotoData->[1]->{storageId}, $photoData->[1]->{storageId}, '... and storage 1 is duplicated');
|
||||||
|
|
||||||
WebGUI::Storage->get($session, $newPhotoData->[0]->{storageId})->delete;
|
WebGUI::Test->storagesToDelete( map { $_->{storageId} } @{ $newPhotoData } );
|
||||||
WebGUI::Storage->get($session, $newPhotoData->[1]->{storageId})->delete;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -368,8 +370,6 @@ END {
|
||||||
$story->purge if $story;
|
$story->purge if $story;
|
||||||
$archive->purge if $archive;
|
$archive->purge if $archive;
|
||||||
$topic->purge if $topic;
|
$topic->purge if $topic;
|
||||||
$storage1->delete if $storage1;
|
|
||||||
$storage2->delete if $storage2;
|
|
||||||
$archiveTag->rollback;
|
$archiveTag->rollback;
|
||||||
WebGUI::VersionTag->getWorking($session)->rollback;
|
WebGUI::VersionTag->getWorking($session)->rollback;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ my %originalConfig;
|
||||||
my $originalSetting;
|
my $originalSetting;
|
||||||
|
|
||||||
my @groupsToDelete;
|
my @groupsToDelete;
|
||||||
|
my @storagesToDelete;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
|
|
@ -140,6 +141,15 @@ END {
|
||||||
foreach my $group (@groupsToDelete) {
|
foreach my $group (@groupsToDelete) {
|
||||||
$group->delete;
|
$group->delete;
|
||||||
}
|
}
|
||||||
|
foreach my $stor (@storagesToDelete) {
|
||||||
|
if ($SESSION->id->valid($stor)) {
|
||||||
|
my $storage = WebGUI::Storage->get($SESSION, $stor);
|
||||||
|
$storage->delete if $storage;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$stor->delete;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($ENV{WEBGUI_TEST_DEBUG}) {
|
if ($ENV{WEBGUI_TEST_DEBUG}) {
|
||||||
$Test->diag('Sessions: '.$SESSION->db->quickScalar('select count(*) from userSession'));
|
$Test->diag('Sessions: '.$SESSION->db->quickScalar('select count(*) from userSession'));
|
||||||
$Test->diag('Scratch : '.$SESSION->db->quickScalar('select count(*) from userSessionScratch'));
|
$Test->diag('Scratch : '.$SESSION->db->quickScalar('select count(*) from userSessionScratch'));
|
||||||
|
|
@ -393,6 +403,8 @@ sub originalConfig {
|
||||||
Push a list of group objects onto the stack of groups to be automatically deleted
|
Push a list of group objects onto the stack of groups to be automatically deleted
|
||||||
at the end of the test.
|
at the end of the test.
|
||||||
|
|
||||||
|
This is a class method.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub groupsToDelete {
|
sub groupsToDelete {
|
||||||
|
|
@ -402,6 +414,22 @@ sub groupsToDelete {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 storagesToDelete ( $storage, [$storageId ] )
|
||||||
|
|
||||||
|
Push a list of storage objects or storageIds onto the stack of storage locaitons
|
||||||
|
at the end of the test.
|
||||||
|
|
||||||
|
This is a class method.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub storagesToDelete {
|
||||||
|
my $class = shift;
|
||||||
|
push @storagesToDelete, @_;
|
||||||
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
=head1 BUGS
|
=head1 BUGS
|
||||||
|
|
||||||
When trying to load the APR module, perl invariably throws an Out Of Memory
|
When trying to load the APR module, perl invariably throws an Out Of Memory
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue