Test maintenance in t/Macro

This commit is contained in:
Colin Kuskie 2009-10-29 10:51:12 -07:00
parent 404ff5d570
commit 3058600737
6 changed files with 13 additions and 77 deletions

View file

@ -14,6 +14,7 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Macro::CanEditText;
use Data::Dumper;
my $session = WebGUI::Test->session;
@ -61,17 +62,10 @@ my @testSets = (
},
);
my $numTests = scalar @testSets + 2;
my $numTests = scalar @testSets + 1;
plan tests => $numTests;
my $macro = 'WebGUI::Macro::CanEditText';
my $loaded = use_ok($macro);
SKIP: {
skip "Unable to load $macro", $numTests-1 unless $loaded;
is(
WebGUI::Macro::CanEditText::process($session,''),
'',
@ -85,8 +79,6 @@ foreach my $testSet (@testSets) {
is($output, $testSet->{output}, $testSet->{comment});
}
}
sub setupTest {
my ($session, $defaultNode) = @_;
$session->user({userId=>3});

View file

@ -15,12 +15,13 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Macro::D_date;
use Data::Dumper;
# ---- END DO NOT EDIT ----
use Test::More; # increment this value for each test you create
my $wgbday = 997966800;
my $wgbday = WebGUI::Test->webguiBirthday;
my @testSets = (
{
@ -33,17 +34,10 @@ my @testSets = (
},
);
my $numTests = scalar @testSets + 1 + 1;
my $numTests = scalar @testSets + 1;
plan tests => $numTests;
my $macro = 'WebGUI::Macro::D_date';
my $loaded = use_ok($macro);
SKIP: {
skip "Unable to load $macro", $numTests-1 unless $loaded;
my $session = WebGUI::Test->session;
foreach my $testSet (@testSets) {
@ -65,5 +59,3 @@ while ($time1 != $time2) {
}
is($output, $session->datetime->epochToHuman($time1), 'checking default time and format');
}

View file

@ -15,6 +15,7 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use HTML::TokeParser;
use WebGUI::Macro::EditableToggle;
use Data::Dumper;
use Test::More; # increment this value for each test you create
@ -184,17 +185,10 @@ foreach my $testSet (@testSets) {
$numTests += 1 + (ref $testSet->{output} eq 'CODE');
}
$numTests += 1 + 1; ##Empty session Asset plus use_ok
$numTests += 1; ##Empty session Asset plus use_ok
plan tests => $numTests;
my $macro = 'WebGUI::Macro::EditableToggle';
my $loaded = use_ok($macro);
SKIP: {
skip "Unable to load $macro", $numTests-1 unless $loaded;
is(
WebGUI::Macro::EditableToggle::process($session,'on','off',''),
'',
@ -229,8 +223,6 @@ foreach my $testSet (@testSets) {
}
}
}
sub simpleHTMLParser {
my ($text) = @_;
my $p = HTML::TokeParser->new(\$text);
@ -255,7 +247,6 @@ sub setupTest {
my ($session, $defaultNode) = @_;
$session->user({userId=>3});
my $editGroup = WebGUI::Group->new($session, "new");
WebGUI::Test->groupsToDelete($editGroup);
my $tao = WebGUI::Group->find($session, "Turn Admin On");
##Create an asset with specific editing privileges
my $versionTag = WebGUI::VersionTag->getWorking($session);
@ -278,12 +269,6 @@ sub setupTest {
$users[1]->addToGroups([$editGroup->getId]);
##User 2 is an editor AND can turn on Admin
$users[2]->addToGroups([$editGroup->getId, $tao->getId]);
WebGUI::Test->usersToDelete(@users);
addToCleanup($versionTag, $editGroup, @users);
return ($versionTag, $asset, @users);
}
END { ##Clean-up after yourself, always
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
$versionTag->rollback;
}
}

View file

@ -14,6 +14,7 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Macro::Extras;
use Test::More; # increment this value for each test you create
@ -49,20 +50,11 @@ my @testSets = (
my $numTests = scalar @testSets;
$numTests += 1;
plan tests => $numTests;
my $macro = 'WebGUI::Macro::Extras';
my $loaded = use_ok($macro);
SKIP: {
skip "Unable to load $macro", $numTests-1 unless $loaded;
foreach my $testSet (@testSets) {
my $output = WebGUI::Macro::Extras::process($session, $testSet->{path});
is($output, $testSet->{output}, $testSet->{comment});
}
}

View file

@ -14,24 +14,14 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Macro::c_companyName;
use Data::Dumper;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
my $numTests = 2+1;
plan tests => $numTests;
my $macro = 'WebGUI::Macro::c_companyName';
my $loaded = use_ok($macro);
my $originalCompanyName = $session->setting->get('companyName');
SKIP: {
skip "Unable to load $macro", $numTests-1 unless $loaded;
plan tests => 2;
my $output = WebGUI::Macro::c_companyName::process($session);
is($output, $originalCompanyName, "Testing companyName");
@ -39,8 +29,3 @@ is($output, $originalCompanyName, "Testing companyName");
$session->setting->set('companyName', q|Gooey's Consulting, LLC|);
$output = WebGUI::Macro::c_companyName::process($session);
is($output, q|Gooey's Consulting, LLC|, "Testing companyName with embedded quote and comma");
}
END {
}

View file

@ -14,26 +14,16 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Macro::e_companyEmail;
use Data::Dumper;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
my $numTests = 1 + 1;
plan tests => $numTests;
my $macro = 'WebGUI::Macro::e_companyEmail';
my $loaded = use_ok($macro);
SKIP: {
skip "Unable to load $macro", $numTests-1 unless $loaded;
plan tests => 1;
my ($value) = $session->dbSlave->quickArray(
"select value from settings where name='companyEmail'");
my $output = WebGUI::Macro::e_companyEmail::process($session);
is($output, $value, sprintf "Testing companyEmail");
}