From 7034e2cf57f933d23af8799ee9d6990daf29fae0 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 7 Jun 2010 19:07:45 -0700 Subject: [PATCH] More END block cleanups. --- t/AssetAspect/RssFeed.t | 8 +--- t/Macro/CartItemCount.t | 37 ++++++++----------- t/Macro/FilePump.t | 6 --- t/Macro/H_homeLink.t | 8 +--- t/Workflow/Activity/CalendarUpdateFeeds.t | 7 +--- t/Workflow/Activity/DeleteExpiredSessions.t | 5 +-- .../ExpireIncompleteSurveyResponses.t | 5 +-- t/Workflow/Activity/GetCsMail.t | 5 --- t/Workflow/Activity/RecheckVATNumber.t | 5 --- t/lib/WebGUI/Test.pm | 3 +- 10 files changed, 25 insertions(+), 64 deletions(-) diff --git a/t/AssetAspect/RssFeed.t b/t/AssetAspect/RssFeed.t index 466372e96..014a6ca42 100644 --- a/t/AssetAspect/RssFeed.t +++ b/t/AssetAspect/RssFeed.t @@ -48,6 +48,7 @@ my $dummy = WebGUI::Asset->getDefault($session)->addChild({ synopsis => 'Dummy Synopsis', description => 'Dummy Description', }); +WebGUI::Test->addToCleanup($dummy); ##################################################### # @@ -191,11 +192,4 @@ cmp_bag( # ##################################################### -#---------------------------------------------------------------------------- -# Cleanup -END { - $dummy->purge; - my $tag = WebGUI::VersionTag->getWorking($session, 'noCreate'); - $tag->rollback if $tag; -} #vim:ft=perl diff --git a/t/Macro/CartItemCount.t b/t/Macro/CartItemCount.t index 94b9575e6..b2482c484 100644 --- a/t/Macro/CartItemCount.t +++ b/t/Macro/CartItemCount.t @@ -31,36 +31,29 @@ my $macro = 'WebGUI::Macro::CartItemCount'; my $loaded = use_ok($macro); my $cart = WebGUI::Shop::Cart->newBySession($session); +WebGUI::Test->addToCleanup($cart); my $donation = WebGUI::Asset->getRoot($session)->addChild({ className => 'WebGUI::Asset::Sku::Donation', title => 'Charitable donation', defaultPrice => 10.00, }); +WebGUI::Test->addToCleanup($donation); -SKIP: { +my $output; -skip "Unable to load $macro", $numTests-1 unless $loaded; +$output = WebGUI::Macro::CartItemCount::process($session); +is ($output, '0', 'Empty cart returns 0 items'); - my $output; +my $item1 = $cart->addItem($donation); +$output = WebGUI::Macro::CartItemCount::process($session); +is ($output, '1', 'Cart contains 1 item'); - $output = WebGUI::Macro::CartItemCount::process($session); - is ($output, '0', 'Empty cart returns 0 items'); +my $item2 = $cart->addItem($donation); +$output = WebGUI::Macro::CartItemCount::process($session); +is ($output, '2', 'Cart contains 2 items, 1 each'); - my $item1 = $cart->addItem($donation); - $output = WebGUI::Macro::CartItemCount::process($session); - is ($output, '1', 'Cart contains 1 item'); +$item2->setQuantity(10); +$output = WebGUI::Macro::CartItemCount::process($session); +is ($output, '11', 'Cart contains 11 items, 1 and 10'); - my $item2 = $cart->addItem($donation); - $output = WebGUI::Macro::CartItemCount::process($session); - is ($output, '2', 'Cart contains 2 items, 1 each'); - - $item2->setQuantity(10); - $output = WebGUI::Macro::CartItemCount::process($session); - is ($output, '11', 'Cart contains 11 items, 1 and 10'); - -} - -END { - $cart->delete; - $donation->purge; -} +#vim:ft=perl diff --git a/t/Macro/FilePump.t b/t/Macro/FilePump.t index b5e8e0ea7..cb5237e33 100644 --- a/t/Macro/FilePump.t +++ b/t/Macro/FilePump.t @@ -113,11 +113,5 @@ is( '... check illegal file type access returns empty string' ); -#---------------------------------------------------------------------------- -# Cleanup -END { -$bundle->delete; - -} #vim:ft=perl diff --git a/t/Macro/H_homeLink.t b/t/Macro/H_homeLink.t index 951996d67..6aad1723e 100644 --- a/t/Macro/H_homeLink.t +++ b/t/Macro/H_homeLink.t @@ -22,6 +22,7 @@ use Test::More; # increment this value for each test you create my $session = WebGUI::Test->session; my ($versionTag, $template) = addTemplate(); +WebGUI::Test->addToCleanup($versionTag); my $homeAsset = WebGUI::Asset->getDefault($session); @@ -126,9 +127,4 @@ sub simpleTextParser { return ($url, $label); } - -END { - if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') { - $versionTag->rollback; - } -} +#vim:ft=perl diff --git a/t/Workflow/Activity/CalendarUpdateFeeds.t b/t/Workflow/Activity/CalendarUpdateFeeds.t index 7c1392e97..6d8cbd84f 100644 --- a/t/Workflow/Activity/CalendarUpdateFeeds.t +++ b/t/Workflow/Activity/CalendarUpdateFeeds.t @@ -74,6 +74,7 @@ my $workflow = WebGUI::Workflow->create($session, mode => 'realtime', }, ); +WebGUI::Test->addToCleanup($workflow); my $icalFetch = $workflow->addActivity('WebGUI::Workflow::Activity::CalendarUpdateFeeds'); my $instance1 = WebGUI::Workflow::Instance->create($session, @@ -127,8 +128,4 @@ is(scalar @{ $newEvents }, 1, 'reimport does not create new children'); $anniversary = pop @{ $newEvents }; is($anniversary->get('description'), $party->get('description'), '... description, checks for line unwrapping'); -END { - $instance1 && $instance1->delete('skipNotify'); - $instance2 && $instance2->delete('skipNotify'); - $workflow && $workflow->delete; -} +#vim:ft=perl diff --git a/t/Workflow/Activity/DeleteExpiredSessions.t b/t/Workflow/Activity/DeleteExpiredSessions.t index 2164ac6d9..6a364d910 100644 --- a/t/Workflow/Activity/DeleteExpiredSessions.t +++ b/t/Workflow/Activity/DeleteExpiredSessions.t @@ -30,6 +30,7 @@ my $workflow = WebGUI::Workflow->create($session, mode => 'realtime', }, ); +WebGUI::Test->addToCleanup($workflow); my $activity = $workflow->addActivity('WebGUI::Workflow::Activity::DeleteExpiredSessions'); my $instance1 = WebGUI::Workflow::Instance->create($session, @@ -113,6 +114,4 @@ foreach my $testSession (@sessions) { ## Make sure that one scratch session was deleted and the other kept. ## Close and end all four sessions -END { - $workflow->delete; -} +#vim:ft=perl diff --git a/t/Workflow/Activity/ExpireIncompleteSurveyResponses.t b/t/Workflow/Activity/ExpireIncompleteSurveyResponses.t index 8dc6a208f..c187a3fe0 100644 --- a/t/Workflow/Activity/ExpireIncompleteSurveyResponses.t +++ b/t/Workflow/Activity/ExpireIncompleteSurveyResponses.t @@ -158,7 +158,4 @@ is($session->db->quickScalar('select count(*) from Survey_response where Survey_ # Afterwards, back to no incomplete responses is( scalar $session->db->buildArray($SQL), 0, 'Afterwards, back to no incomplete responses'); -END { - $session->db->write('delete from Survey_response where userId = ?', [$user->userId]) if $user; - $survey->purge if $survey; -} +#vim:ft=perl diff --git a/t/Workflow/Activity/GetCsMail.t b/t/Workflow/Activity/GetCsMail.t index da874f98d..2bba5d725 100644 --- a/t/Workflow/Activity/GetCsMail.t +++ b/t/Workflow/Activity/GetCsMail.t @@ -143,9 +143,4 @@ $post2mock->set_always('getId', $post2_id); WebGUI::Test->unmockAssetId($post_id); } -#---------------------------------------------------------------------------- -# Cleanup -END { - -} #vim:ft=perl diff --git a/t/Workflow/Activity/RecheckVATNumber.t b/t/Workflow/Activity/RecheckVATNumber.t index 04d2d6010..8502a9f61 100644 --- a/t/Workflow/Activity/RecheckVATNumber.t +++ b/t/Workflow/Activity/RecheckVATNumber.t @@ -112,9 +112,4 @@ sub createInstance { -#---------------------------------------------------------------------------- -# Cleanup -END { - -} #vim:ft=perl diff --git a/t/lib/WebGUI/Test.pm b/t/lib/WebGUI/Test.pm index b8d1bf10e..57518cf00 100644 --- a/t/lib/WebGUI/Test.pm +++ b/t/lib/WebGUI/Test.pm @@ -895,9 +895,10 @@ Example call: 'WebGUI::Shop::Vendor' => 'delete', 'WebGUI::Inbox::Message' => 'purge', 'WebGUI::AdSpace' => 'delete', + 'WebGUI::FilePump::Bundle' => 'delete', 'WebGUI::Shop::Cart' => sub { my $cart = shift; - my $addressBook = $cart->getAddressBook(); + my $addressBook = eval { $cart->getAddressBook(); }; $addressBook->delete if $addressBook; ##Should we call cleanupGuard instead??? $cart->delete; },