diff --git a/t/Macro/GroupText.t b/t/Macro/GroupText.t index 562e389f4..72b97821c 100644 --- a/t/Macro/GroupText.t +++ b/t/Macro/GroupText.t @@ -13,7 +13,6 @@ use strict; use lib "$FindBin::Bin/../lib"; use WebGUI::Test; -use WebGUI::Macro::GroupText; use WebGUI::Session; use WebGUI::Group; use WebGUI::User; @@ -22,7 +21,23 @@ my $session = WebGUI::Test->session; use Test::More; # increment this value for each test you create -plan tests => 3 + 4; +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; @@ -45,7 +60,7 @@ $session->db->dbh->do(q!CREATE TABLE myUserTable (userId varchar(22) binary NOT ##Create a bunch of users and put them in the table. -my @mob = map { WebGUI::User->new($session, "new") } 0..3; +@mob = map { WebGUI::User->new($session, "new") } 0..3; my $sth = $session->db->prepare('INSERT INTO myUserTable VALUES(?)'); foreach my $mob (@mob) { $sth->execute([ $mob->userId ]); @@ -53,9 +68,9 @@ foreach my $mob (@mob) { ##Create the 3 groups -my $ms_users = WebGUI::Group->new($session, "new"); -my $ms_distributors = WebGUI::Group->new($session, "new"); -my $ms_int_distributors = WebGUI::Group->new($session, "new"); +$ms_users = WebGUI::Group->new($session, "new"); +$ms_distributors = WebGUI::Group->new($session, "new"); +$ms_int_distributors = WebGUI::Group->new($session, "new"); $ms_users->name('MS Users'); $ms_distributors->name('MS Distributors'); @@ -75,8 +90,8 @@ $ms_distributors->addGroups([$ms_int_distributors->getId]); ##Add two users for testing the two groups -my $disti = WebGUI::User->new($session, 'new'); -my $int_disti = WebGUI::User->new($session, 'new'); +$disti = WebGUI::User->new($session, 'new'); +$int_disti = WebGUI::User->new($session, 'new'); $ms_distributors->addUsers([$disti->userId]); $ms_int_distributors->addUsers([$int_disti->userId]); @@ -105,6 +120,8 @@ $output = join ',', ; is($output, 'user,disti,int_disti', 'user is in all three groups'); +} + ##clean up everything END { foreach my $testGroup ($ms_users, $ms_distributors, $ms_int_distributors, ) { diff --git a/t/Macro/H_homeLink.t b/t/Macro/H_homeLink.t index 35dcae76b..d497330f9 100644 --- a/t/Macro/H_homeLink.t +++ b/t/Macro/H_homeLink.t @@ -13,7 +13,6 @@ use strict; use lib "$FindBin::Bin/../lib"; use WebGUI::Test; -use WebGUI::Macro::H_homeLink; use WebGUI::Session; use HTML::TokeParser; use Data::Dumper; @@ -63,8 +62,17 @@ foreach my $testSet (@testSets) { $numTests += 1 + (ref $testSet->{output} eq 'CODE'); } +$numTests += 1; #For the use_ok + plan tests => $numTests; +my $macro = 'WebGUI::Macro::H_homeLink'; +my $loaded = use_ok($macro); + +SKIP: { + +skip "Unable to load $macro", $numTests-1 unless $loaded; + foreach my $testSet (@testSets) { my $output = WebGUI::Macro::H_homeLink::process($session, $testSet->{label}, $testSet->{template}); if (ref $testSet->{output} eq 'CODE') { @@ -77,6 +85,8 @@ foreach my $testSet (@testSets) { } } +} + sub addTemplate { $session->user({userId=>3}); my $importNode = WebGUI::Asset->getImportNode($session); diff --git a/t/Macro/Hash_userId.t b/t/Macro/Hash_userId.t index f5aeac037..fca720bac 100644 --- a/t/Macro/Hash_userId.t +++ b/t/Macro/Hash_userId.t @@ -15,7 +15,6 @@ use strict; use lib "$FindBin::Bin/../lib"; use WebGUI::Test; -use WebGUI::Macro::Hash_userId; use WebGUI::Session; use Data::Dumper; @@ -36,10 +35,21 @@ 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/Include.t b/t/Macro/Include.t index 7a248468d..d99fc1d8d 100644 --- a/t/Macro/Include.t +++ b/t/Macro/Include.t @@ -13,7 +13,6 @@ use strict; use lib "$FindBin::Bin/../lib"; use WebGUI::Test; -use WebGUI::Macro::Include; use WebGUI::Session; use WebGUI::Storage; @@ -33,8 +32,7 @@ my $storage = WebGUI::Storage->createTemp($session); $storage->addFileFromScalar('goodFile', $goodFile); $storage->addFileFromScalar('twoLines', $twoLines); $storage->addFileFromScalar('unreadableFile', 'The contents of this file are not readable'); -chmod 0111, $storage->getPath('unreadableFile') - or diag($!); +chmod(0111, $storage->getPath('unreadableFile')) or diag($!); my @testSets = ( { @@ -96,13 +94,24 @@ my @testSets = ( my $numTests = scalar @testSets; +$numTests += 1; #For the use_ok + 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}); my $passed = is($output, $testSet->{output}, $testSet->{comment} . ":" .$testSet->{file}); } +} + END { $storage->delete; } diff --git a/t/Macro/International.t b/t/Macro/International.t index 8249a280d..26e8a9e52 100644 --- a/t/Macro/International.t +++ b/t/Macro/International.t @@ -43,8 +43,9 @@ my @testSets = ( }, ); -my $numTests = scalar @testSets + 1; +my $numTests = scalar @testSets; +$numTests += 1; plan tests => $numTests; my $loaded = use_ok('WebGUI::Macro::International'); diff --git a/t/Macro/LastModified.t b/t/Macro/LastModified.t index dca3feda7..cf58a1c7e 100644 --- a/t/Macro/LastModified.t +++ b/t/Macro/LastModified.t @@ -13,7 +13,6 @@ use strict; use lib "$FindBin::Bin/../lib"; use WebGUI::Test; -use WebGUI::Macro::LastModified; use WebGUI::Session; use Test::More; # increment this value for each test you create @@ -48,15 +47,28 @@ my @testSets = ( }, ); -my $numTests = scalar @testSets + 2; +my $numTests = scalar @testSets; + +$numTests += 1; #For the use_ok +$numTests += 2; #For TODO tests plan tests => $numTests; +my $macro = 'WebGUI::Macro::LastModified'; +my $loaded = use_ok($macro); + +SKIP: { + +skip "Unable to load $macro", $numTests-1 unless $loaded; + + foreach my $testSet (@testSets) { my $output = WebGUI::Macro::LastModified::process($session, $testSet->{label}, $testSet->{format}); is($output, $testSet->{output}, $testSet->{comment}); } +} + TODO: { local $TODO = "Tests to make later"; ok(0, 'Check label and format'); diff --git a/t/Macro/LoginToggle.t b/t/Macro/LoginToggle.t index 338ca1b27..36fb51db7 100644 --- a/t/Macro/LoginToggle.t +++ b/t/Macro/LoginToggle.t @@ -131,9 +131,15 @@ foreach my $testSet (@testSets) { $numTests += 1 + (ref $testSet->{parser} eq 'CODE'); } -plan tests => $numTests + 1; +$numTests += 1; #for the use_ok +plan tests => $numTests; -use_ok('WebGUI::Macro::LoginToggle'); +my $macro = 'WebGUI::Macro::LoginToggle'; +my $loaded = use_ok($macro); + +SKIP: { + +skip "Unable to load $macro", $numTests-1 unless $loaded; foreach my $testSet (@testSets) { $session->user({userId=>$testSet->{userId}}); @@ -157,6 +163,8 @@ foreach my $testSet (@testSets) { } } +} + sub simpleHTMLParser { my ($text) = @_; my $p = HTML::TokeParser->new(\$text); diff --git a/t/Macro/Page.t b/t/Macro/Page.t index f14bf30f2..cddb7ab01 100644 --- a/t/Macro/Page.t +++ b/t/Macro/Page.t @@ -13,7 +13,6 @@ use strict; use lib "$FindBin::Bin/../lib"; use WebGUI::Test; -use WebGUI::Macro::Page; use WebGUI::Session; use Data::Dumper; @@ -47,13 +46,22 @@ foreach my $testSet (@testSets) { $numTests += scalar keys %{ $testSet }; } +$numTests += 1; #For the use_ok + plan tests => $numTests; +my $macro = 'WebGUI::Macro::Page'; +my $loaded = use_ok($macro); + my $homeAsset = WebGUI::Asset->getDefault($session); my $versionTag; ($versionTag, @testSets) = setupTest($session, $homeAsset, @testSets); +SKIP: { + +skip "Unable to load $macro", $numTests-1 unless $loaded; + foreach my $testSet (@testSets) { $session->asset($testSet->{asset}); my $class = $testSet->{className}; @@ -65,6 +73,8 @@ foreach my $testSet (@testSets) { } } +} + sub setupTest { my ($session, $homeAsset, @testSets) = @_; my $versionTag = WebGUI::VersionTag->getWorking($session); diff --git a/t/Macro/PageTitle.t b/t/Macro/PageTitle.t index 71aa8dac5..589ce2ac8 100644 --- a/t/Macro/PageTitle.t +++ b/t/Macro/PageTitle.t @@ -13,7 +13,6 @@ use strict; use lib "$FindBin::Bin/../lib"; use WebGUI::Test; -use WebGUI::Macro::PageTitle; use WebGUI::Session; use Data::Dumper; @@ -21,15 +20,18 @@ use Test::More; # increment this value for each test you create my $session = WebGUI::Test->session; -plan tests => 2; +my $numTests = 2; +$numTests += 1; #For the use_ok + +plan tests => $numTests; + +my $macro = 'WebGUI::Macro::PageTitle'; +my $loaded = use_ok($macro); my $homeAsset = WebGUI::Asset->getDefault($session); -##Make the homeAsset the default asset in the session. -$session->asset($homeAsset); - -my $output = WebGUI::Macro::PageTitle::process($session); -is($output, $homeAsset->get('title'), 'fetching title for site default asset'); +my $versionTag = WebGUI::VersionTag->getWorking($session); +$versionTag->set({name=>"PageTitle macro test"}); # Create a new snippet and set it's title then check it against the macros output my $snippetTitle = "Roy's Incredible Snippet of Mystery and Intrique"; @@ -40,6 +42,25 @@ my $snippet = $homeAsset->addChild({ groupIdView=>7, groupIdEdit=>3, }); + +$versionTag->commit; + +SKIP: { + +skip "Unable to load $macro", $numTests-1 unless $loaded; + +##Make the homeAsset the default asset in the session. +$session->asset($homeAsset); + +my $output = WebGUI::Macro::PageTitle::process($session); +is($output, $homeAsset->get('title'), 'fetching title for site default asset'); + $session->asset($snippet); my $macroOutput = WebGUI::Macro::PageTitle::process($session); is($macroOutput, $snippet->get('title'), "testing title returned from localy created asset with known title"); + +} + +END { + $versionTag->rollback; +}