diff --git a/t/Macro/FormParam.t b/t/Macro/FormParam.t index 78d1e41f9..c608eaf2f 100644 --- a/t/Macro/FormParam.t +++ b/t/Macro/FormParam.t @@ -57,6 +57,8 @@ my $numTests = scalar @testSets; $numTests += 1; ##testBlock has no name collisions $numTests += 3; ##TODO block +plan tests => $numTests; + auto_check($session, \@testSets); TODO: { diff --git a/t/Macro/GroupText.t b/t/Macro/GroupText.t index c3f066066..e09085017 100644 --- a/t/Macro/GroupText.t +++ b/t/Macro/GroupText.t @@ -16,6 +16,7 @@ use WebGUI::Test; use WebGUI::Session; use WebGUI::Group; use WebGUI::User; +use WebGUI::Macro::GroupText; my $session = WebGUI::Test->session; @@ -24,21 +25,13 @@ use Test::More; # increment this value for each test you create my $numTests; $numTests = 3; #Direct Macro tests $numTests += 4; #Bug tests -$numTests += 1; #For the use_ok plan tests => $numTests; -my $macro = 'WebGUI::Macro::GroupText'; -my $loaded = use_ok($macro); - my @mob; my ($ms_users, $ms_distributors, $ms_int_distributors); my ($disti, $int_disti); -SKIP: { - -skip "Unable to load $macro", $numTests-1 unless $loaded; - my $output; $session->user({userId => 1}); @@ -65,14 +58,14 @@ my $sth = $session->db->prepare('INSERT INTO myUserTable VALUES(?)'); foreach my $mob (@mob) { $sth->execute([ $mob->userId ]); } -WebGUI::Test->usersToDelete(@mob); +addToCleanup(@mob); ##Create the 3 groups $ms_users = WebGUI::Group->new($session, "new"); $ms_distributors = WebGUI::Group->new($session, "new"); $ms_int_distributors = WebGUI::Group->new($session, "new"); -WebGUI::Test->groupsToDelete($ms_users, $ms_distributors, $ms_int_distributors); +addToCleanup($ms_users, $ms_distributors, $ms_int_distributors); $ms_users->name('MS Users'); $ms_distributors->name('MS Distributors'); @@ -94,7 +87,7 @@ $ms_distributors->addGroups([$ms_int_distributors->getId]); $disti = WebGUI::User->new($session, 'new'); $int_disti = WebGUI::User->new($session, 'new'); -WebGUI::Test->usersToDelete($disti, $int_disti); +addToCleanup($disti, $int_disti); $ms_distributors->addUsers([$disti->userId]); $ms_int_distributors->addUsers([$int_disti->userId]); @@ -123,8 +116,6 @@ $output = join ',', ; is($output, 'user,disti,int_disti', 'user is in all three groups'); -} - ##clean up everything END { $session->db->dbh->do('DROP TABLE IF EXISTS myUserTable'); diff --git a/t/Macro/Hash_userId.t b/t/Macro/Hash_userId.t index 064c25465..cd2f2fca9 100644 --- a/t/Macro/Hash_userId.t +++ b/t/Macro/Hash_userId.t @@ -16,6 +16,7 @@ use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::Session; +use WebGUI::Macro::Hash_userId; use Data::Dumper; my $session = WebGUI::Test->session; @@ -35,21 +36,10 @@ my @testSets = ( my $numTests = scalar @testSets; -$numTests += 1; #For the use_ok - plan tests => $numTests; -my $macro = 'WebGUI::Macro::Hash_userId'; -my $loaded = use_ok($macro); - -SKIP: { - -skip "Unable to load $macro", $numTests-1 unless $loaded; - foreach my $testSet (@testSets) { $session->user({userId => $testSet->{userId}}); my $output = WebGUI::Macro::Hash_userId::process($session); is($output, $testSet->{userId}, 'testing '.$testSet->{comment}); } - -} diff --git a/t/Macro/If.t b/t/Macro/If.t index c6563018a..fe2e929d4 100644 --- a/t/Macro/If.t +++ b/t/Macro/If.t @@ -14,23 +14,17 @@ use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::Session; +use WebGUI::Macro::If; use Data::Dumper; my $session = WebGUI::Test->session; use Test::More; # increment this value for each test you create -my $numTests = 8 + 1; # For conditional load and skip +my $numTests = 8; # For conditional load and skip plan tests => $numTests; -my $macro = 'WebGUI::Macro::If'; -my $loaded = use_ok($macro); - -SKIP: { - -skip "Unable to load $macro", $numTests-1 unless $loaded; - my $output; $output = WebGUI::Macro::If::process($session, '', 'full', 'empty'); @@ -56,5 +50,3 @@ is($output, 'There are 5 lights', 'true text works with sprintf'); $output = WebGUI::Macro::If::process($session, 0, 'Full', 'There are %s lights'); is($output, 'There are %s lights', '...false text does not'); - -} diff --git a/t/Macro/Include.t b/t/Macro/Include.t index a10fab767..cf57e7452 100644 --- a/t/Macro/Include.t +++ b/t/Macro/Include.t @@ -15,6 +15,7 @@ use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::Session; use WebGUI::Storage; +use WebGUI::Macro::Include; use Test::More; # increment this value for each test you create @@ -85,18 +86,10 @@ my @testSets = ( my $numTests = scalar @testSets; -$numTests += 1; #For the use_ok $numTests += 1; #For the unreadable file test plan tests => $numTests; -my $macro = 'WebGUI::Macro::Include'; -my $loaded = use_ok($macro); - -SKIP: { - -skip "Unable to load $macro", $numTests-1 unless $loaded; - foreach my $testSet (@testSets) { my $output = WebGUI::Macro::Include::process($session, $testSet->{file}); is($output, $testSet->{output}, $testSet->{comment} . ":" .$testSet->{file}); @@ -109,8 +102,3 @@ SKIP: { my $output = WebGUI::Macro::Include::process($session, $file); is($output, $i18n->get('not found'), q|Unreadable file returns NOT FOUND|. ":" .$file); } - -} - -END { -} diff --git a/t/Macro/International.t b/t/Macro/International.t index 5aa5b97dd..ae4033da5 100644 --- a/t/Macro/International.t +++ b/t/Macro/International.t @@ -14,6 +14,7 @@ use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::Session; +use WebGUI::Macro::International; use Data::Dumper; use Test::More; # increment this value for each test you create @@ -50,18 +51,9 @@ my @testSets = ( my $numTests = scalar @testSets; -$numTests += 1; plan tests => $numTests; -my $loaded = use_ok('WebGUI::Macro::International'); - -SKIP: { - -skip 'Module was not loaded, skipping all tests', $numTests -1 unless $loaded; - foreach my $testSet (@testSets) { my $output = WebGUI::Macro::International::process($session, @{ $testSet->{input} }); is($output, $testSet->{output}, $testSet->{comment} ); } - -} diff --git a/t/Macro/LastModified.t b/t/Macro/LastModified.t index 285a9219c..5907bae34 100644 --- a/t/Macro/LastModified.t +++ b/t/Macro/LastModified.t @@ -14,6 +14,7 @@ use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::Session; +use WebGUI::Macro::LastModified; use Test::More; # increment this value for each test you create @@ -46,17 +47,12 @@ my @testSets = ( my $numTests = scalar @testSets; -$numTests += 1 + 2; #For the use_ok, default asset, and revisionDate=0 +$numTests += 2; #For the use_ok, default asset, and revisionDate=0 plan tests => $numTests; -my $macro = 'WebGUI::Macro::LastModified'; -my $loaded = use_ok($macro); my $versionTag = WebGUI::VersionTag->getWorking($session); - -SKIP: { - -skip "Unable to load $macro", $numTests-1 unless $loaded; +addToCleanup($versionTag); my $output = WebGUI::Macro::LastModified::process($session); is($output, '', "Macro returns '' if no asset is defined"); @@ -97,11 +93,3 @@ is($output, $i18n->get('never'), 'asset with 0 revisionDate returns never modifi ##Restore the original revisionDate, otherwise it dies during clean-up $session->db->write('update assetData set revisionDate=? where assetId=?', [$revDate, $assetA->getId]); - -} - -END { ##Clean-up after yourself, always - if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') { - $versionTag->rollback; - } -}