diff --git a/t/Macro/AdminText.t b/t/Macro/AdminText.t
index a3b62e461..021544bdc 100644
--- a/t/Macro/AdminText.t
+++ b/t/Macro/AdminText.t
@@ -13,10 +13,9 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::AdminText;
use WebGUI::Session;
use Data::Dumper;
-use WebGUI::Macro_Config;
my $session = WebGUI::Test->session;
@@ -26,34 +25,19 @@ my $numTests = 4;
plan tests => $numTests;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'AdminText', 'AdminText');
-
-my $adminText = "^AdminText(admin);";
my $output;
-$output = $adminText;
-WebGUI::Macro::process($session, \$output);
+$output = WebGUI::Macro::AdminText::process($session, 'admin');
is($output, '', 'user is not admin');
$session->user({userId => 3});
-$output = $adminText;
-WebGUI::Macro::process($session, \$output);
+$output = WebGUI::Macro::AdminText::process($session, 'admin');
is($output, '', 'user is admin, not in admin mode');
$session->var->switchAdminOn;
-$output = $adminText;
-WebGUI::Macro::process($session, \$output);
+$output = WebGUI::Macro::AdminText::process($session, 'admin');
is($output, 'admin', 'admin in admin mode');
$session->var->switchAdminOff;
-$output = $adminText;
-WebGUI::Macro::process($session, \$output);
+$output = WebGUI::Macro::AdminText::process($session, 'admin');
is($output, '', 'user is admin, not in admin mode');
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/AdminToggle.t b/t/Macro/AdminToggle.t
index b6a522980..d43919a0d 100644
--- a/t/Macro/AdminToggle.t
+++ b/t/Macro/AdminToggle.t
@@ -13,7 +13,7 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::AdminToggle;
use WebGUI::Session;
use WebGUI::Macro_Config;
use HTML::TokeParser;
@@ -23,10 +23,6 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'AdminToggle', 'AdminToggle');
-
my ($versionTag, $template) = addTemplate();
my $homeAsset = WebGUI::Asset->getDefault($session);
@@ -121,7 +117,6 @@ foreach my $testSet (@testSets) {
plan tests => $numTests + 1;
foreach my $testSet (@testSets) {
- my $output = sprintf $testSet->{macroText}, $testSet->{onText}, $testSet->{offText}, $testSet->{template};
$session->user({userId=>$testSet->{userId}});
if ($testSet->{adminStatus} eq 'off') {
$session->var->switchAdminOff();
@@ -134,7 +129,8 @@ foreach my $testSet (@testSets) {
else {
BAIL_OUT('Unknown admin status selected');
}
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::AdminToggle::process( $session,
+ $testSet->{onText}, $testSet->{offText}, $testSet->{template} );
if (ref $testSet->{output} eq 'CODE') {
my ($url, $label) = $testSet->{output}->($output);
is($label, $testSet->{label}, $testSet->{comment}.", label");
@@ -192,8 +188,4 @@ END {
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
$versionTag->rollback;
}
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/At_username.t b/t/Macro/At_username.t
index 4799f0c25..a40199429 100644
--- a/t/Macro/At_username.t
+++ b/t/Macro/At_username.t
@@ -13,10 +13,9 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::At_username;
use WebGUI::Session;
use Data::Dumper;
-use WebGUI::Macro_Config;
my $session = WebGUI::Test->session;
@@ -26,24 +25,12 @@ my $numTests = 2;
plan tests => $numTests;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, '@', 'At_username');
-
-my $macroText = "^@;";
my $output;
-$output = $macroText;
-WebGUI::Macro::process($session, \$output);
+$session->user({userId => 1});
+$output = WebGUI::Macro::At_username::process($session);
is($output, 'Visitor', 'username = Visitor');
-$output = $macroText;
$session->user({userId => 3});
-WebGUI::Macro::process($session, \$output);
+$output = WebGUI::Macro::At_username::process($session);
is($output, 'Admin', 'username = Admin');
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/CanEditText.t b/t/Macro/CanEditText.t
index 945a8a7c7..5d21a7767 100644
--- a/t/Macro/CanEditText.t
+++ b/t/Macro/CanEditText.t
@@ -13,18 +13,14 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::CanEditText;
use WebGUI::Session;
use Data::Dumper;
-use WebGUI::Macro_Config;
my $session = WebGUI::Test->session;
use Test::More; # increment this value for each test you create
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'CanEditText', 'CanEditText');
-
my $adminText = "^CanEditText(editor);";
my $output;
@@ -36,7 +32,6 @@ my @testSets = (
{
comment => 'Visitor sees nothing',
userId => 1,
- macroText => q!^CanEditText("%s");!,
text => q!I am an editor!,
asset => $asset,
output => '',
@@ -44,7 +39,6 @@ my @testSets = (
{
comment => 'Admin sees text',
userId => 3,
- macroText => q!^CanEditText("%s");!,
text => q!I am an editor!,
asset => $asset,
output => 'I am an editor',
@@ -52,7 +46,6 @@ my @testSets = (
{
comment => 'Random user sees nothing',
userId => $users[0]->userId,
- macroText => q!^CanEditText("%s");!,
text => q!I am an editor!,
asset => $asset,
output => '',
@@ -60,7 +53,6 @@ my @testSets = (
{
comment => 'General Content Manager sees nothing',
userId => $users[1]->userId,
- macroText => q!^CanEditText("%s");!,
text => q!I am an editor!,
asset => $asset,
output => '',
@@ -68,7 +60,6 @@ my @testSets = (
{
comment => 'Member of group to edit this asset sees text',
userId => $users[2]->userId,
- macroText => q!^CanEditText("%s");!,
text => q!I am an editor!,
asset => $asset,
output => 'I am an editor',
@@ -82,8 +73,7 @@ plan tests => $numTests;
foreach my $testSet (@testSets) {
$session->user({userId=>$testSet->{userId}});
$session->asset($testSet->{asset});
- my $output = sprintf $testSet->{macroText}, $testSet->{text};
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::CanEditText::process($session, $testSet->{text});
is($output, $testSet->{output}, $testSet->{comment});
}
@@ -125,8 +115,4 @@ END { ##Clean-up after yourself, always
foreach my $dude (@users) {
$dude->delete if (defined $dude and ref $dude eq 'WebGUI::User');
}
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/D_date.t b/t/Macro/D_date.t
index 1205c8dab..e1c945d93 100644
--- a/t/Macro/D_date.t
+++ b/t/Macro/D_date.t
@@ -14,9 +14,8 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::D_date;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
# ---- END DO NOT EDIT ----
@@ -28,12 +27,12 @@ my $output;
my @testSets = (
{
- format => '%%%c%d%h',
- output =>'%August1608',
+ format => '%%%c%d%h',
+ output =>'%August1608',
},
{
- format => '',
- output =>'8/16/2001 8:00 am',
+ format => '',
+ output =>'8/16/2001 8:00 am',
},
);
@@ -43,18 +42,7 @@ plan tests => $numTests;
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'D', 'Date');
-
foreach my $testSet (@testSets) {
- $output = sprintf $macroText, $testSet->{format}, $wgbday;
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::D_date::process($session, $testSet->{format}, $wgbday);
is($output, $testSet->{output}, 'testing '.$testSet->{format});
}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/EditableToggle.t b/t/Macro/EditableToggle.t
index 525d945f3..d54887f62 100644
--- a/t/Macro/EditableToggle.t
+++ b/t/Macro/EditableToggle.t
@@ -13,9 +13,8 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::EditableToggle;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use HTML::TokeParser;
use Data::Dumper;
@@ -23,9 +22,6 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'EditableToggle', 'EditableToggle');
-
my $homeAsset = WebGUI::Asset->getDefault($session);
$session->asset($homeAsset);
my ($versionTag, $asset, @users) = setupTest($session, $homeAsset);
@@ -208,7 +204,6 @@ foreach my $testSet (@testSets) {
plan tests => $numTests;
foreach my $testSet (@testSets) {
- my $output = sprintf $testSet->{macroText}, $testSet->{onText}, $testSet->{offText}, $testSet->{template};
$session->user({userId=>$testSet->{userId}});
$session->asset($testSet->{asset});
if ($testSet->{adminStatus} eq 'off') {
@@ -224,7 +219,8 @@ foreach my $testSet (@testSets) {
else {
BAIL_OUT('Unknown admin status selected');
}
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::EditableToggle::process($session,
+ $testSet->{onText}, $testSet->{offText}, $testSet->{template});
if (ref $testSet->{output} eq 'CODE') {
my ($url, $label) = $testSet->{output}->($output);
is($label, $testSet->{label}, $testSet->{comment}.", label");
@@ -290,8 +286,4 @@ END { ##Clean-up after yourself, always
foreach my $dude (@users) {
$dude->delete if (defined $dude and ref $dude eq 'WebGUI::User');
}
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/Extras.t b/t/Macro/Extras.t
index a31b22771..c8bbf7fa3 100644
--- a/t/Macro/Extras.t
+++ b/t/Macro/Extras.t
@@ -13,7 +13,7 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::Extras;
use WebGUI::Session;
use WebGUI::Macro_Config;
@@ -21,29 +21,31 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'Extras', 'Extras');
-
my @testSets = (
- { ##Just get the extras path
- macroText => q!^Extras();!,
- path => q!!,
- output => $session->url->extras(),
+ {
+ comment => 'Just get the extras path',
+ path => q!!,
+ output => $session->url->extras(),
},
- { ##Note that trailing slash is appended
- macroText => q!^Extras();!,
- path => q!!,
- output => $session->config->get("extrasURL").'/',
+ {
+ comment => 'Note that trailing slash is appended',
+ path => q!!,
+ output => $session->config->get("extrasURL").'/',
},
- { ##append a path, example from docs
- macroText => q!^Extras(%s);!,
- path => q!path/to/something/in/extras/folder!,
- output => $session->url->extras('path/to/something/in/extras/folder'),
+ {
+ comment => 'undef vs empty string',
+ path => undef,
+ output => $session->config->get("extrasURL").'/',
},
- { ##double slashes are removed
- macroText => q!^Extras(%s);!,
- path => q!/path/to/something/in/extras/folder!,
- output => $session->url->extras('path/to/something/in/extras/folder'),
+ {
+ comment => 'append a path, example from docs',
+ path => q!path/to/something/in/extras/folder!,
+ output => $session->url->extras('path/to/something/in/extras/folder'),
+ },
+ {
+ comment => 'double slashes are removed',
+ path => q!/path/to/something/in/extras/folder!,
+ output => $session->url->extras('path/to/something/in/extras/folder'),
},
);
@@ -52,16 +54,7 @@ my $numTests = scalar @testSets;
plan tests => $numTests;
foreach my $testSet (@testSets) {
- my $output = sprintf $testSet->{macroText}, $testSet->{path};
- my $macro = $output;
- WebGUI::Macro::process($session, \$output);
- is($output, $testSet->{output}, 'testing '.$macro);
-}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
+ my $output = WebGUI::Macro::Extras::process($session, $testSet->{path});
+ is($output, $testSet->{output}, $testSet->{comment});
}
diff --git a/t/Macro/FetchMimeType.t b/t/Macro/FetchMimeType.t
index af85528fc..c88436ef5 100644
--- a/t/Macro/FetchMimeType.t
+++ b/t/Macro/FetchMimeType.t
@@ -13,40 +13,33 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::FetchMimeType;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'FetchMimeType', 'FetchMimeType');
-
-my $macroText = '^FetchMimeType("%s");';
-my $output;
-
my @testSets = (
{
- input => 'plainblack.gif',
- output => 'image/gif',
- comment => q|gif|,
+ input => 'plainblack.gif',
+ output => 'image/gif',
+ comment => q|gif|,
},
{
- input => 'background.jpg',
- output => 'image/jpeg',
- comment => q|jpeg|,
+ input => 'background.jpg',
+ output => 'image/jpeg',
+ comment => q|jpeg|,
},
{
- input => 'colorPicker.js',
- output => 'text/plain',
- comment => q|plain text|,
+ input => 'colorPicker.js',
+ output => 'text/plain',
+ comment => q|plain text|,
},
{
- input => 'favIcon.ico',
- output => 'application/octet-stream',
- comment => q|octet-stream for unknown type|,
+ input => 'favIcon.ico',
+ output => 'application/octet-stream',
+ comment => q|octet-stream for unknown type|,
},
);
@@ -54,17 +47,9 @@ my $numTests = scalar @testSets;
plan tests => $numTests;
-
foreach my $testSet (@testSets) {
my $file = join '/', WebGUI::Test->root, 'www/extras', $testSet->{input};
- $output = sprintf $macroText, $file;
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::FetchMimeType::process($session, $file);
is($output, $testSet->{output}, $testSet->{comment} );
}
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/FileUrl.t b/t/Macro/FileUrl.t
index 104204823..dd67c5457 100644
--- a/t/Macro/FileUrl.t
+++ b/t/Macro/FileUrl.t
@@ -13,9 +13,8 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::FileUrl;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use WebGUI::Storage;
use Data::Dumper;
@@ -24,9 +23,6 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
my $i18n = WebGUI::International->new($session, 'Macro_FileUrl');
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'FileUrl', 'FileUrl');
-
##Add more Asset configurations here.
my @testSets = (
{
@@ -95,8 +91,7 @@ my $versionTag;
($versionTag, @testSets) = setupTest($session, $homeAsset, @testSets);
foreach my $testSet (@testSets) {
- my $output = sprintf $macroText, $testSet->{url};
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::FileUrl::process($session, $testSet->{url});
if ($testSet->{pass}) {
is($output, $testSet->{fileUrl}, $testSet->{comment});
}
@@ -137,9 +132,4 @@ sub setupTest {
END { ##Clean-up after yourself, always
$versionTag->rollback;
-
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/GroupAdd.t b/t/Macro/GroupAdd.t
index 978db39a2..317fd3868 100644
--- a/t/Macro/GroupAdd.t
+++ b/t/Macro/GroupAdd.t
@@ -13,9 +13,8 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::GroupAdd;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
use Test::More; # increment this value for each test you create
@@ -23,16 +22,12 @@ use HTML::TokeParser;
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'GroupAdd', 'GroupAdd');
-
my $homeAsset = WebGUI::Asset->getDefault($session);
my ($versionTag, $template, $groups, $users) = setupTest($session, $homeAsset);
my @testSets = (
{
comment => 'Empty macro call returns null string',
- macroText => q!^GroupAdd();!,
groupName => '',
text => '',
template => '',
@@ -41,7 +36,6 @@ my @testSets = (
},
{
comment => 'Empty group returns null string',
- macroText => q!^GroupAdd("%s","%s");!,
groupName => '',
text => 'Join up',
template => '',
@@ -50,7 +44,6 @@ my @testSets = (
},
{
comment => 'Empty text returns null string',
- macroText => q!^GroupAdd("%s","%s");!,
groupName => $groups->[0]->name,
text => '',
template => '',
@@ -59,7 +52,6 @@ my @testSets = (
},
{
comment => 'Visitor sees empty string with valid group and text',
- macroText => q!^GroupAdd("%s","%s");!,
groupName => $groups->[0]->name(),
text => 'Join up!',
template => '',
@@ -68,7 +60,6 @@ my @testSets = (
},
{
comment => 'Non-existant group returns null string',
- macroText => q!^GroupAdd("%s","%s");!,
groupName => "Dudes of the day",
text => 'Join up!',
template => '',
@@ -77,7 +68,6 @@ my @testSets = (
},
{
comment => 'Group without autoAdd returns null string',
- macroText => q!^GroupAdd("%s","%s");!,
groupName => $groups->[1]->name,
text => 'Join up!',
template => '',
@@ -86,7 +76,6 @@ my @testSets = (
},
{
comment => 'Existing member of group sees empty string',
- macroText => q!^GroupAdd("%s","%s");!,
groupName => $groups->[0]->name,
text => 'Join up!',
template => '',
@@ -95,7 +84,6 @@ my @testSets = (
},
{
comment => 'Non-member of group sees text and link',
- macroText => q!^GroupAdd("%s","%s");!,
groupName => $groups->[0]->name,
groupId => $groups->[0]->getId,
text => 'Join up!',
@@ -106,7 +94,6 @@ my @testSets = (
},
{
comment => 'Member of different group sees text and link',
- macroText => q!^GroupAdd("%s","%s");!,
groupName => $groups->[0]->name,
groupId => $groups->[0]->getId,
text => 'Join up!',
@@ -117,7 +104,6 @@ my @testSets = (
},
{
comment => 'Custom template check',
- macroText => q!^GroupAdd("%s","%s","%s");!,
groupName => $groups->[0]->name,
groupId => $groups->[0]->getId,
text => 'Join up!',
@@ -138,9 +124,8 @@ plan tests => $numTests;
foreach my $testSet (@testSets) {
$session->user({ userId => $testSet->{userId} });
- my $output = sprintf $testSet->{macroText},
- $testSet->{groupName}, $testSet->{text}, $testSet->{template};
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::GroupAdd::process($session,
+ $testSet->{groupName}, $testSet->{text}, $testSet->{template});
if ($testSet->{empty}) {
is($output, '', $testSet->{comment});
}
@@ -216,8 +201,4 @@ END { ##Clean-up after yourself, always
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
$versionTag->rollback;
}
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/GroupDelete.t b/t/Macro/GroupDelete.t
index 9ec2d82fb..c4e6d4e76 100644
--- a/t/Macro/GroupDelete.t
+++ b/t/Macro/GroupDelete.t
@@ -13,9 +13,8 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::GroupDelete;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
use Test::More; # increment this value for each test you create
@@ -23,16 +22,12 @@ use HTML::TokeParser;
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'GroupDelete', 'GroupDelete');
-
my $homeAsset = WebGUI::Asset->getDefault($session);
my ($versionTag, $template, $groups, $users) = setupTest($session, $homeAsset);
my @testSets = (
{
comment => 'Empty macro call returns null string',
- macroText => q!^GroupDelete();!,
groupName => '',
text => '',
template => '',
@@ -41,7 +36,6 @@ my @testSets = (
},
{
comment => 'Empty group returns null string',
- macroText => q!^GroupDelete("%s","%s");!,
groupName => '',
text => 'Bow out',
template => '',
@@ -50,7 +44,6 @@ my @testSets = (
},
{
comment => 'Empty text returns null string',
- macroText => q!^GroupDelete("%s","%s");!,
groupName => $groups->[0]->name,
text => '',
template => '',
@@ -59,7 +52,6 @@ my @testSets = (
},
{
comment => 'Visitor sees empty string with valid group and text',
- macroText => q!^GroupDelete("%s","%s");!,
groupName => $groups->[0]->name(),
text => 'Bow out',
template => '',
@@ -68,7 +60,6 @@ my @testSets = (
},
{
comment => 'Non-existant group returns null string',
- macroText => q!^GroupDelete("%s","%s");!,
groupName => "Dudes of the day",
text => 'Bow out',
template => '',
@@ -77,7 +68,6 @@ my @testSets = (
},
{
comment => 'Group without autoDelete returns null string',
- macroText => q!^GroupDelete("%s","%s");!,
groupName => $groups->[1]->name,
text => 'Bow out',
template => '',
@@ -86,7 +76,6 @@ my @testSets = (
},
{
comment => 'Non-member of group sees empty string',
- macroText => q!^GroupDelete("%s","%s");!,
groupName => $groups->[0]->name,
text => 'Bow out',
template => '',
@@ -95,7 +84,6 @@ my @testSets = (
},
{
comment => 'Member of different group sees empty string',
- macroText => q!^GroupDelete("%s","%s");!,
groupName => $groups->[0]->name,
groupId => $groups->[0]->getId,
text => 'Bow out',
@@ -105,7 +93,6 @@ my @testSets = (
},
{
comment => 'Member of group sees text and link',
- macroText => q!^GroupDelete("%s","%s");!,
groupName => $groups->[0]->name,
groupId => $groups->[0]->getId,
text => 'Bow out',
@@ -116,7 +103,6 @@ my @testSets = (
},
{
comment => 'Custom template check',
- macroText => q!^GroupDelete("%s","%s","%s");!,
groupName => $groups->[0]->name,
groupId => $groups->[0]->getId,
text => 'Bow out',
@@ -137,9 +123,8 @@ plan tests => $numTests;
foreach my $testSet (@testSets) {
$session->user({ userId => $testSet->{userId} });
- my $output = sprintf $testSet->{macroText},
- $testSet->{groupName}, $testSet->{text}, $testSet->{template};
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::GroupDelete::process($session,
+ $testSet->{groupName}, $testSet->{text}, $testSet->{template});
if ($testSet->{empty}) {
is($output, '', $testSet->{comment});
}
@@ -215,8 +200,4 @@ END { ##Clean-up after yourself, always
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
$versionTag->rollback;
}
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/GroupText.t b/t/Macro/GroupText.t
index 37a258198..562e389f4 100644
--- a/t/Macro/GroupText.t
+++ b/t/Macro/GroupText.t
@@ -13,11 +13,10 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::GroupText;
use WebGUI::Session;
use WebGUI::Group;
use WebGUI::User;
-use WebGUI::Macro_Config;
my $session = WebGUI::Test->session;
@@ -25,24 +24,17 @@ use Test::More; # increment this value for each test you create
plan tests => 3 + 4;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'GroupText', 'GroupText');
-
-my $macroText = q!^GroupText("Admins","admin","visitor");!;
my $output;
$session->user({userId => 1});
-$output = $macroText;
-WebGUI::Macro::process($session, \$output);
+$output = WebGUI::Macro::GroupText::process($session, "Admins", "admin", "visitor");
is($output, 'visitor', 'user is not admin');
$session->user({userId => 3});
-$output = $macroText;
-WebGUI::Macro::process($session, \$output);
+$output = WebGUI::Macro::GroupText::process($session, "Admins", "admin", "visitor");
is($output, 'admin', 'user is admin');
-$output = q!^GroupText("Not a Group","in group","outside group");!;
-WebGUI::Macro::process($session, \$output);
+$output = WebGUI::Macro::GroupText::process($session, "Not a Group","in group","outside group");
is($output, 'Group Not a Group was not found', 'Non-existant group returns an error message');
##Bug test setup
@@ -89,21 +81,28 @@ my $int_disti = WebGUI::User->new($session, 'new');
$ms_distributors->addUsers([$disti->userId]);
$ms_int_distributors->addUsers([$int_disti->userId]);
-$macroText = q!^GroupText("MS Users","user","not");,^GroupText("MS Distributors","disti","not");,^GroupText("MS International Distributors","int_disti","not");!;
-
$session->user({userId => $mob[0]->userId});
-$output = $macroText;
-WebGUI::Macro::process($session, \$output);
+$output = join ',',
+ WebGUI::Macro::GroupText::process($session, "MS Users","user","not"),
+ WebGUI::Macro::GroupText::process($session, "MS Distributors","disti","not"),
+ WebGUI::Macro::GroupText::process($session, "MS International Distributors","int_disti","not"),
+ ;
is($output, 'user,not,not', 'user is ms user');
$session->user({userId => $disti->userId});
-$output = $macroText;
-WebGUI::Macro::process($session, \$output);
+$output = join ',',
+ WebGUI::Macro::GroupText::process($session, "MS Users","user","not"),
+ WebGUI::Macro::GroupText::process($session, "MS Distributors","disti","not"),
+ WebGUI::Macro::GroupText::process($session, "MS International Distributors","int_disti","not"),
+ ;
is($output, 'user,disti,not', 'user is ms user and distributor');
$session->user({userId => $int_disti->userId});
-$output = $macroText;
-WebGUI::Macro::process($session, \$output);
+$output = join ',',
+ WebGUI::Macro::GroupText::process($session, "MS Users","user","not"),
+ WebGUI::Macro::GroupText::process($session, "MS Distributors","disti","not"),
+ WebGUI::Macro::GroupText::process($session, "MS International Distributors","int_disti","not"),
+ ;
is($output, 'user,disti,int_disti', 'user is in all three groups');
##clean up everything
@@ -115,9 +114,4 @@ END {
$dude->delete if (defined $dude and ref $dude eq 'WebGUI::User');
}
$session->db->dbh->do('DROP TABLE IF EXISTS myUserTable');
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
-
diff --git a/t/Macro/H_homeLink.t b/t/Macro/H_homeLink.t
index f21b4eb77..35dcae76b 100644
--- a/t/Macro/H_homeLink.t
+++ b/t/Macro/H_homeLink.t
@@ -13,9 +13,8 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::H_homeLink;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use HTML::TokeParser;
use Data::Dumper;
@@ -23,9 +22,6 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'H', 'H_homeLink');
-
my ($versionTag, $template) = addTemplate();
my $homeAsset = WebGUI::Asset->getDefault($session);
@@ -34,14 +30,12 @@ my $i18n = WebGUI::International->new($session,'Macro_H_homeLink');
my @testSets = (
{
- macroText => q!^H("%s");!,
label => q!linkonly!,
template => q!!,
output => $homeAsset->getUrl(),
comment => 'linkonly argument',
},
{
- macroText => q!^H();!,
label => $i18n->get(47),
template => q!!,
url => $homeAsset->getUrl(),
@@ -49,7 +43,6 @@ my @testSets = (
comment => 'default macro call',
},
{
- macroText => q!^H("%s");!,
label => q!Hi, want to go home?!,
template => q!!,
url => $homeAsset->getUrl(),
@@ -57,7 +50,6 @@ my @testSets = (
comment => 'custom label',
},
{
- macroText => q!^H("%s","%s");!,
label => q!Custom label!,
template => q!H_homeLink-test!,
url => $homeAsset->getUrl(),
@@ -74,8 +66,7 @@ foreach my $testSet (@testSets) {
plan tests => $numTests;
foreach my $testSet (@testSets) {
- my $output = sprintf $testSet->{macroText}, $testSet->{label}, $testSet->{template};
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::H_homeLink::process($session, $testSet->{label}, $testSet->{template});
if (ref $testSet->{output} eq 'CODE') {
my ($url, $label) = $testSet->{output}->($output);
is($label, $testSet->{label}, $testSet->{comment}.", label");
@@ -128,8 +119,4 @@ END {
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
$versionTag->rollback;
}
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/Hash_userId.t b/t/Macro/Hash_userId.t
index fa83d666b..f5aeac037 100644
--- a/t/Macro/Hash_userId.t
+++ b/t/Macro/Hash_userId.t
@@ -15,26 +15,22 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::Hash_userId;
use WebGUI::Session;
use Data::Dumper;
-use WebGUI::Macro_Config;
my $session = WebGUI::Test->session;
use Test::More; # increment this value for each test you create
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, '#', 'Hash_userId');
-
my @testSets = (
{
- userId => 1,
- comment => q!Visitor!,
+ userId => 1,
+ comment => q!Visitor!,
},
{
- userId => 3,
- comment => q!Admin!,
+ userId => 3,
+ comment => q!Admin!,
},
);
@@ -44,14 +40,6 @@ plan tests => $numTests;
foreach my $testSet (@testSets) {
$session->user({userId => $testSet->{userId}});
- my $output = "^#;";
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::Hash_userId::process($session);
is($output, $testSet->{userId}, 'testing '.$testSet->{comment});
}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/International.t b/t/Macro/International.t
index 98c64995e..82df1649d 100644
--- a/t/Macro/International.t
+++ b/t/Macro/International.t
@@ -13,41 +13,37 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::International;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'International', 'International');
-
my $macroText = '^International("%s","%s");';
my $output;
my @testSets = (
{
- input => ['macroName', 'Macro_International'],
- output => q!International!,
- comment => q|explicit namespace|,
+ input => ['macroName', 'Macro_International'],
+ output => q!International!,
+ comment => q|explicit namespace|,
},
{
- input => ['international title', 'Macro_International'],
- output => q!International Macro!,
- comment => q|space in label|,
+ input => ['international title', 'Macro_International'],
+ output => q!International Macro!,
+ comment => q|space in label|,
},
{
- input => ['webgui', 'WebGUI'],
- output => q!WebGUI!,
- comment => q|explicit namespace #2|,
+ input => ['webgui', 'WebGUI'],
+ output => q!WebGUI!,
+ comment => q|explicit namespace #2|,
},
{
- input => ['webgui', ''],
- output => q!WebGUI!,
- comment => q|default namespace|,
+ input => ['webgui', ''],
+ output => q!WebGUI!,
+ comment => q|default namespace|,
},
);
@@ -55,16 +51,7 @@ my $numTests = scalar @testSets;
plan tests => $numTests;
-
foreach my $testSet (@testSets) {
- $output = sprintf $macroText, @{ $testSet->{input} };
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::International::process($session, @{ $testSet->{input} });
is($output, $testSet->{output}, $testSet->{comment} );
}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/LastModified.t b/t/Macro/LastModified.t
index e81effed5..dca3feda7 100644
--- a/t/Macro/LastModified.t
+++ b/t/Macro/LastModified.t
@@ -13,17 +13,13 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::LastModified;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'LastModified', 'LastModified');
-
my $homeAsset = WebGUI::Asset->getDefault($session);
##Make the homeAsset the default asset in the session.
@@ -33,25 +29,22 @@ my ($time) = $session->dbSlave->quickArray("SELECT max(revisionDate) FROM assetD
my @testSets = (
{
- macroText => q!^LastModified();!,
- label => q!!,
- format => q!!,
- output => $session->datetime->epochToHuman($time,'%z'),
- comment => 'checking defaults with empty args',
+ label => q!!,
+ format => q!!,
+ output => $session->datetime->epochToHuman($time,'%z'),
+ comment => 'checking defaults with empty args',
},
{
- macroText => q!^LastModified("%s");!,
- label => q!Last modified on: !,
- format => q!!,
- output => 'Last modified on: '.$session->datetime->epochToHuman($time,'%z'),
- comment => 'checking label, empty format',
+ label => q!Last modified on: !,
+ format => q!!,
+ output => 'Last modified on: '.$session->datetime->epochToHuman($time,'%z'),
+ comment => 'checking label, empty format',
},
{
- macroText => q!^LastModified("%s","%s");!,
- label => '',
- format => q!%c %y!,
- output => $session->datetime->epochToHuman($time,'%c %y'),
- comment => 'checking format, empty label',
+ label => '',
+ format => q!%c %y!,
+ output => $session->datetime->epochToHuman($time,'%c %y'),
+ comment => 'checking format, empty label',
},
);
@@ -60,8 +53,7 @@ my $numTests = scalar @testSets + 2;
plan tests => $numTests;
foreach my $testSet (@testSets) {
- my $output = sprintf $testSet->{macroText}, $testSet->{label}, $testSet->{format};
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::LastModified::process($session, $testSet->{label}, $testSet->{format});
is($output, $testSet->{output}, $testSet->{comment});
}
@@ -70,10 +62,3 @@ TODO: {
ok(0, 'Check label and format');
ok(0, 'Create asset with revisionDate = 0 and check label "never"');
}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/Page.t b/t/Macro/Page.t
index 7a6a9ca39..f14bf30f2 100644
--- a/t/Macro/Page.t
+++ b/t/Macro/Page.t
@@ -13,18 +13,14 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::Page;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'Page', 'Page');
-
##Add more Asset configurations here.
my @testSets = (
{
@@ -53,9 +49,6 @@ foreach my $testSet (@testSets) {
plan tests => $numTests;
-my $macroText = '^Page("%s");';
-my $output = $macroText;
-
my $homeAsset = WebGUI::Asset->getDefault($session);
my $versionTag;
@@ -66,8 +59,7 @@ foreach my $testSet (@testSets) {
my $class = $testSet->{className};
foreach my $field (keys %{ $testSet }) {
next if $field eq 'asset';
- my $output = sprintf $macroText, $field;
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::Page::process($session, $field);
my $comment = sprintf "Checking asset: %s, field: %s", $class, $field;
is($output, $testSet->{$field}, $comment);
}
@@ -88,8 +80,4 @@ sub setupTest {
END { ##Clean-up after yourself, always
$versionTag->rollback;
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/PageTitle.t b/t/Macro/PageTitle.t
index f4d6be4a4..452c84d7b 100644
--- a/t/Macro/PageTitle.t
+++ b/t/Macro/PageTitle.t
@@ -13,41 +13,25 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::PageTitle;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'PageTitle', 'PageTitle');
-
-my $macroText = '^PageTitle;';
-my $output;
-
plan tests => 2;
-$output = $macroText;
-
my $homeAsset = WebGUI::Asset->getDefault($session);
##Make the homeAsset the default asset in the session.
$session->asset($homeAsset);
-WebGUI::Macro::process($session, \$output);
+my $output = WebGUI::Macro::PageTitle::process($session);
is($output, $homeAsset->get('title'), 'fetching title for site default asset');
TODO: {
local $TODO = "Tests to make later";
ok(0, 'Fetch title from locally made asset with known title');
}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/PageUrl.t b/t/Macro/PageUrl.t
index 8f284f38b..b4f956052 100644
--- a/t/Macro/PageUrl.t
+++ b/t/Macro/PageUrl.t
@@ -13,41 +13,25 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::PageUrl;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'PageUrl', 'PageUrl');
-
-my $macroText = '^PageUrl;';
-my $output;
-
plan tests => 2;
-$output = $macroText;
-
my $homeAsset = WebGUI::Asset->getDefault($session);
##Make the homeAsset the default asset in the session.
$session->asset($homeAsset);
-WebGUI::Macro::process($session, \$output);
+my $output = WebGUI::Macro::PageUrl::process($session);
is($output, $session->url->gateway.$homeAsset->get('url'), 'fetching url for site default asset');
TODO: {
local $TODO = "Tests to make later";
ok(0, 'Fetch url from locally made asset with known url');
}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/Quote.t b/t/Macro/Quote.t
index 8f40dcf94..e43fccd52 100644
--- a/t/Macro/Quote.t
+++ b/t/Macro/Quote.t
@@ -13,33 +13,26 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::Quote;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'Quote', 'Quote');
-
-my $macroText = '^Quote("%s");';
-my $output;
-
my @testSets = (
{
- input => q!that's great!,
- output => q!'that\\'s great'!,
+ input => q!that's great!,
+ output => q!'that\\'s great'!,
},
{
- input => q!0!,
- output => q!'0'!,
+ input => q!0!,
+ output => q!'0'!,
},
{
- input => q!!,
- output => q!''!,
+ input => q!!,
+ output => q!''!,
},
);
@@ -47,16 +40,7 @@ my $numTests = scalar @testSets;
plan tests => $numTests;
-
foreach my $testSet (@testSets) {
- $output = sprintf $macroText, $testSet->{input};
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::Quote::process($session, $testSet->{input});
is($output, $testSet->{output}, 'testing '.$testSet->{input});
}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/RootTitle.t b/t/Macro/RootTitle.t
new file mode 100644
index 000000000..619a52a65
--- /dev/null
+++ b/t/Macro/RootTitle.t
@@ -0,0 +1,152 @@
+#-------------------------------------------------------------------
+# WebGUI is Copyright 2001-2006 Plain Black Corporation.
+#-------------------------------------------------------------------
+# Please read the legal notices (docs/legal.txt) and the license
+# (docs/license.txt) that came with this distribution before using
+# this software.
+#-------------------------------------------------------------------
+# http://www.plainblack.com info@plainblack.com
+#-------------------------------------------------------------------
+
+use FindBin;
+use strict;
+use lib "$FindBin::Bin/../lib";
+
+use WebGUI::Test;
+use WebGUI::Macro::RootTitle;
+use WebGUI::Session;
+use Data::Dumper;
+
+use Test::More; # increment this value for each test you create
+
+my $session = WebGUI::Test->session;
+
+##Build this structure in Snippet Assets because it's easy
+# defaultRoot
+# / | \
+# / | \
+# / | \
+# A Z defaultHome <=== "ROOTS"
+# | / \
+# B Y X
+
+#my $versionTag = WebGUI::VersionTag->getWorking($session);
+#$versionTag->set({name=>"Adding assets for RootTitle tests"});
+
+my $root = WebGUI::Asset->getRoot($session);
+my %properties_A = (
+ className => 'WebGUI::Asset::Snippet',
+ title => 'Asset A',
+ url => 'asset-a',
+ snippet => 'root A',
+ # '1234567890123456789012'
+ id => 'RootA-----------------',
+);
+
+my $versionA = WebGUI::VersionTag->getWorking($session);
+$versionA->set({name=>"Adding asset A"});
+my $assetA = $root->addChild(\%properties_A, $properties_A{id});
+$versionA->commit;
+
+my %properties_B = (
+ className => 'WebGUI::Asset::Snippet',
+ title => 'Asset B',
+ url => 'asset-b',
+ snippet => 'Asset B',
+ # '1234567890123456789012'
+ id => 'RootA-AssetB----------',
+);
+
+my $versionB = WebGUI::VersionTag->getWorking($session);
+$versionB->set({name=>"Adding asset B"});
+my $assetB = $assetA->addChild(\%properties_B, $properties_B{id});
+$versionB->commit;
+
+my %properties_Z = (
+ className => 'WebGUI::Asset::Snippet',
+ title => 'Asset Z',
+ url => 'asset-z',
+ snippet => 'root Z',
+ # '1234567890123456789012'
+ id => 'RootZ-----------------',
+);
+my $versionZ = WebGUI::VersionTag->getWorking($session);
+$versionZ->set({name=>"Adding asset Z"});
+my $assetZ = $root->addChild(\%properties_Z, $properties_Z{id});
+$versionZ->commit;
+
+my %properties_Y = (
+ className => 'WebGUI::Asset::Snippet',
+ title => 'Asset Y',
+ url => 'asset-y',
+ snippet => 'Asset Y',
+ # '1234567890123456789012'
+ id => 'RootZ-AssetY----------',
+);
+my $versionY = WebGUI::VersionTag->getWorking($session);
+$versionY->set({name=>"Adding asset Y"});
+my $assetY = $assetZ->addChild(\%properties_Y, $properties_Y{id});
+$versionY->commit;
+
+my %properties_X = (
+ className => 'WebGUI::Asset::Snippet',
+ title => 'Asset X',
+ url => 'asset-x',
+ snippet => 'Asset X',
+ # '1234567890123456789012'
+ id => 'RootZ-AssetX----------',
+);
+my $versionX = WebGUI::VersionTag->getWorking($session);
+$versionX->set({name=>"Adding asset X"});
+my $assetX = $assetZ->addChild(\%properties_X, $properties_X{id});
+$versionX->commit;
+
+#$versionTag->commit;
+
+my @testSets = (
+ {
+ comment => q!B's root = A!,
+ asset => $assetB,
+ title => $assetA->getTitle,
+ },
+ {
+ comment => q!A's root is itself!,
+ asset => $assetA,
+ title => $assetA->getTitle,
+ },
+ {
+ comment => q!Z's root is itself!,
+ asset => $assetZ,
+ title => $assetZ->getTitle,
+ },
+ {
+ comment => q!X's root = Z!,
+ asset => $assetX,
+ title => $assetZ->getTitle,
+ },
+ {
+ comment => q!Y's root = Z!,
+ asset => $assetY,
+ title => $assetZ->getTitle,
+ },
+);
+
+plan tests => scalar @testSets;
+
+foreach my $testSet (@testSets) {
+ $session->asset($testSet->{asset});
+ my $output = WebGUI::Macro::RootTitle::process($session);
+ is($output, $testSet->{title}, $testSet->{comment});
+}
+
+END { ##Clean-up after yourself, always
+# if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
+# $versionTag->rollback;
+# }
+
+ foreach my $vTag ($versionB, $versionA, $versionX, $versionY, $versionZ) {
+ if (defined $vTag and ref $vTag eq 'WebGUI::VersionTag') {
+ $vTag->rollback;
+ }
+ }
+}
diff --git a/t/Macro/SQL.t b/t/Macro/SQL.t
index f4e7a3bd3..92fbb3aa2 100644
--- a/t/Macro/SQL.t
+++ b/t/Macro/SQL.t
@@ -13,24 +13,16 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::Slash_gatewayUrl;
+use WebGUI::Macro::SQL;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'SQL', 'SQL');
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, '/', 'Slash_gatewayUrl');
-
-my $macroText = '^SQL("%s","%s");';
-
-my $url = "^/;";
-
-WebGUI::Macro::process($session, \$url);
+my $url = WebGUI::Macro::Slash_gatewayUrl::process($session);
$session->db->dbh->do('DROP TABLE IF EXISTS testTable');
$session->db->dbh->do('CREATE TABLE testTable (zero int(8), one int(8), two int(8), three int(8), four int(8), five int(8), six int(8), seven int(8), eight int(8), nine int(8), ten int(8), eleven int(8) ) TYPE=InnoDB');
@@ -38,45 +30,53 @@ $session->db->dbh->do('INSERT INTO testTable (zero, one, two, three, four, five,
$session->db->dbh->do('INSERT INTO testTable (zero, one, two, three, four, five, six, seven, eight, nine, ten, eleven ) VALUES(100,101,102,103,104,105,106,107,108,109,110,111)');
my @testSets = (
- { ##first example from docs
- sql => q!select count(*) from users!,
- template => q!There are ^0; users!,
- output => q!There are 2 users!,
+ {
+ comment => q!first example from docs!,
+ sql => q!select count(*) from users!,
+ template => q!There are ^0; users!,
+ output => q!There are 2 users!,
},
- { ##pretest for second example
- sql => q!select userId,username from users order by username!,
- template => q!^0;:^1;-!,
- output => q!3:Admin-1:Visitor-!,
+ {
+ comment => q!pretest for second example!,
+ sql => q!select userId,username from users order by username!,
+ template => q!^0;:^1;-!,
+ output => q!3:Admin-1:Visitor-!,
},
- { ##second example from docs
- sql => q!select userId,username from users order by username!,
- template => q!^1;
!,
- output => join '', map {sprintf "%s
", @{ $_ }} ([$url, 3,'Admin'],[$url, 1,'Visitor']),
+ {
+ comment => q!second example from docs!,
+ sql => q!select userId,username from users order by username!,
+ template => qq!^1;
!,
+ output => join '', map {sprintf "%s
", @{ $_ }} ([$url, 3,'Admin'],[$url, 1,'Visitor']),
},
- { ##test two digit macros
- sql => q!select * from testTable order by one!,
- template => join(':', map { "^$_;" } 0..11).'-',
- output => '0:1:2:3:4:5:6:7:8:9:10:11-100:101:102:103:104:105:106:107:108:109:110:111-',
+ {
+ comment => q!test two digit macros!,
+ sql => q!select * from testTable order by one!,
+ template => join(':', map { "^$_;" } 0..11).'-',
+ output => '0:1:2:3:4:5:6:7:8:9:10:11-100:101:102:103:104:105:106:107:108:109:110:111-',
},
- { ##Test illegal SQL, update
- sql => q!update testTable set one=201 where one=101!,
- template => '^0;',
- output => 'Cannot execute this type of query.',
+ {
+ comment => q!Test illegal SQL, update!,
+ sql => q!update testTable set one=201 where one=101!,
+ template => '^0;',
+ output => 'Cannot execute this type of query.',
},
- { ##Test illegal SQL, update
- sql => q!INSERT INTO testTable (zero, one, two, three, four, five, six, seven, eight, nine, ten, eleven ) VALUES(200,201,202,203,204,205,206,207,208,209,210,211)!,
- template => '^0;',
- output => 'Cannot execute this type of query.',
+ {
+ comment => q!Test illegal SQL, update!,
+ sql => q!INSERT INTO testTable (zero, one, two, three, four, five, six, seven, eight, nine, ten, eleven ) VALUES(200,201,202,203,204,205,206,207,208,209,210,211)!,
+ template => '^0;',
+ output => 'Cannot execute this type of query.',
},
- { ##Test unused macro variables
- sql => q!select zero,one,two,three from testTable order by one!,
- template => join(':', map { "^$_;" } 0..4).'-',
- output => '0:1:2:3:-100:101:102:103:-',
+ {
+ comment => q!Test unused macro variables!,
+ sql => q!select zero,one,two,three from testTable order by one!,
+ template => join(':', map { "^$_;" } 0..4).'-',
+ output => '0:1:2:3:-100:101:102:103:-',
},
- { ##rownum test
- sql => q!select zero,one,two,three from testTable order by one!,
- template => join(':', map { "^$_;" } 'rownum', 0..3).',',
- output => '1:0:1:2:3,2:100:101:102:103,',
+ {
+ comment => q!rownum test!,
+ sql => q!select zero,one,two,three from testTable order by one!,
+ template => join(':', map { "^$_;" } 'rownum', 0..3).',',
+ output => '1:0:1:2:3,2:100:101:102:103,',
},
);
@@ -84,22 +84,9 @@ my $numTests = scalar @testSets;
plan tests => $numTests;
-unless ($session->config->get('macros')->{'SQL'}) {
- BAIL_OUT('SQL macro not enabled');
-}
-
foreach my $testSet (@testSets) {
- my $output = sprintf $macroText, $testSet->{sql}, $testSet->{template};
- my $macro = $output;
- WebGUI::Macro::process($session, \$output);
- is($output, $testSet->{output}, 'testing '.$macro);
+ my $output = WebGUI::Macro::SQL::process($session, $testSet->{sql}, $testSet->{template});
+ is($output, $testSet->{output}, $testSet->{comment});
}
$session->db->dbh->do('DROP TABLE testTable');
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/SettingMacros.t b/t/Macro/SettingMacros.t
index 2e5b35203..334cc8935 100644
--- a/t/Macro/SettingMacros.t
+++ b/t/Macro/SettingMacros.t
@@ -13,52 +13,17 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::e_companyEmail;
use WebGUI::Session;
use Data::Dumper;
-use WebGUI::Macro_Config;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @settingMacros = (
- {
- settingKey => 'companyEmail',
- macro => 'e_companyEmail'
- },
- {
- settingKey => 'companyName',
- macro => 'c_companyName'
- },
- {
- settingKey => 'companyURL',
- macro => 'u_companyUrl'
- },
-);
+plan tests => 1;
-##Build a reversed hash so we know how to call the macros based on
-##their name
-my @added_macros = ();
-foreach my $macro ( @settingMacros ) {
- $macro->{shortcut} = $macro->{macro};
- push @added_macros,
- WebGUI::Macro_Config::enable_macro($session, $macro->{shortcut}, $macro->{macro});
-}
-
-plan tests => scalar @settingMacros;
-
-foreach my $macro ( @settingMacros ) {
- my ($value) = $session->dbSlave->quickArray(
- "select value from settings where name=?", [$macro->{settingKey}]);
- my $macroVal = sprintf "^%s();", $macro->{shortcut};
- WebGUI::Macro::process($session, \$macroVal);
- is($value, $macroVal, sprintf "Testing %s", $macro->{macro});
-}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
+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");
diff --git a/t/Macro/Slash_gatewayUrl.t b/t/Macro/Slash_gatewayUrl.t
index 4149ab58e..b724b8fd4 100644
--- a/t/Macro/Slash_gatewayUrl.t
+++ b/t/Macro/Slash_gatewayUrl.t
@@ -13,35 +13,19 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::Slash_gatewayUrl;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, '/', 'Slash_gatewayUrl');
-
-my $macroText = '^/;';
-my $output;
-
plan tests => 1;
-$output = $macroText;
-
##Note, this is not a test of the gateway method. That is done over
##in t/Session/Url.t All we need to do is make sure that the macro
##fetches the same thing as the method.
-WebGUI::Macro::process($session, \$output);
+my $output = WebGUI::Macro::Slash_gatewayUrl::process($session);
is($output, $session->url->gateway, 'fetching site gateway');
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/Spacer.t b/t/Macro/Spacer.t
index c83cfb08e..f28849afb 100644
--- a/t/Macro/Spacer.t
+++ b/t/Macro/Spacer.t
@@ -13,9 +13,8 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::Spacer;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use HTML::TokeParser;
use Data::Dumper;
@@ -23,9 +22,6 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'Spacer', 'Spacer');
-
my @testSets = (
{
comment => '5x5',
@@ -56,8 +52,7 @@ my @testSets = (
plan tests => 5 + 2 * scalar @testSets;
foreach my $testSet (@testSets) {
- my $output = sprintf $testSet->{macroText}, $testSet->{width}, $testSet->{height};
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::Spacer::process($session, $testSet->{width}, $testSet->{height});
my ($width, $height) = simpleHTMLParser($output);
is($width, $testSet->{width}, $testSet->{comment}.", width");
is($height, $testSet->{height}, $testSet->{comment}.", height");
@@ -85,10 +80,3 @@ sub simpleHTMLParser {
return ($width, $height, $src, $alt, $style);
}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/Splat_random.t b/t/Macro/Splat_random.t
index 24c486b60..fd2b9a0c7 100644
--- a/t/Macro/Splat_random.t
+++ b/t/Macro/Splat_random.t
@@ -13,11 +13,10 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::Splat_random;
use WebGUI::Session;
use WebGUI::Group;
use WebGUI::User;
-use WebGUI::Macro_Config;
my $session = WebGUI::Test->session;
@@ -30,15 +29,9 @@ use Data::Dumper;
plan tests => 4;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, '*', 'Splat_random');
-
-my $macroText = q!^*(%s);!;
-my $output;
my $inBounds = 1;
BOUNDED: for (my $i=0; $i<=99; $i++) {
- my $output = sprintf $macroText, 10;
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::Splat_random::process($session, 10);
if (($output > 10) or ($output < 0)) {
$inBounds = 0;
last BOUNDED;
@@ -47,14 +40,12 @@ BOUNDED: for (my $i=0; $i<=99; $i++) {
ok($inBounds, "100 fetches were in bounds");
-$output = '^*;';
-WebGUI::Macro::process($session, \$output);
-ok($output >= 0 and $output < 1_000_000_000, "Empty argument returns a number");
+my $output = WebGUI::Macro::Splat_random::process($session);
+ok($output >= 0 and $output < 1_000_000_000, "Empty argument returns a number within default bounds");
my $wholeNumber = 1;
WHOLE: for (my $i=0; $i<=99; $i++) {
- my $output = sprintf $macroText, 1;
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::Splat_random::process($session, 1);
if (int($output) != $output) {
$wholeNumber = 0;
last WHOLE;
@@ -65,18 +56,10 @@ ok($wholeNumber, "100 fetches were all whole numbers");
my @bins = ();
WHOLE: for (my $i=0; $i<=999; $i++) {
- my $output = sprintf $macroText, 4;
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::Splat_random::process($session, 4);
++$bins[$output];
}
is(scalar(@bins), 4, "All bins have values on a sample size of 1000");
#diag Dumper \@bins;
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/Thumbnail.t b/t/Macro/Thumbnail.t
index 21701f134..e79e26c07 100644
--- a/t/Macro/Thumbnail.t
+++ b/t/Macro/Thumbnail.t
@@ -13,9 +13,8 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::Thumbnail;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use WebGUI::Image;
use WebGUI::Storage::Image;
@@ -27,9 +26,6 @@ plan tests => 7;
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'Thumbnail', 'Thumbnail');
-
my $square = WebGUI::Image->new($session, 100, 100);
$square->setBackgroundColor('#0000FF');
@@ -68,10 +64,9 @@ $asset->generateThumbnail();
##Call the Thumbnail Macro with that Asset's URL and see if it returns
##the correct URL.
-my $macroText = sprintf q!^Thumbnail("%s");!, $asset->getUrl();
-WebGUI::Macro::process($session, \$macroText);
+my $output = WebGUI::Macro::Thumbnail::process($session, $asset->getUrl());
my $macroUrl = $storage->getPath('thumb-square.png');
-is($macroText, $asset->getThumbnailUrl, 'Macro returns correct filename');
+is($output, $asset->getThumbnailUrl, 'Macro returns correct filename');
my $thumbUrl = $asset->getThumbnailUrl;
substr($thumbUrl, 0, length($session->config->get("uploadsURL"))) = '';
@@ -92,8 +87,4 @@ END {
$versionTag->rollback;
}
##Storage is cleaned up by rolling back the version tag
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/URLEncode.t b/t/Macro/URLEncode.t
index b458fdde2..5cd6bf55a 100644
--- a/t/Macro/URLEncode.t
+++ b/t/Macro/URLEncode.t
@@ -13,41 +13,34 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::URLEncode;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use Data::Dumper;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'URLEncode', 'URLEncode');
-
-my $macroText = '^URLEncode("%s");';
-my $output;
-
my @testSets = (
{
- input => q! !,
- output => q!%20!,
- comment => q|space|,
+ input => q! !,
+ output => q!%20!,
+ comment => q|space|,
},
{
- input => q!/!,
- output => q!%2F!,
- comment => q|slash|,
+ input => q!/!,
+ output => q!%2F!,
+ comment => q|slash|,
},
{
- input => q!abcde!,
- output => q!abcde!,
- comment => q|alpha|,
+ input => q!abcde!,
+ output => q!abcde!,
+ comment => q|alpha|,
},
{
- input => q!&!,
- output => q!%26!,
- comment => q|ampersand|,
+ input => q!&!,
+ output => q!%26!,
+ comment => q|ampersand|,
},
);
@@ -55,16 +48,7 @@ my $numTests = scalar @testSets;
plan tests => $numTests;
-
foreach my $testSet (@testSets) {
- $output = sprintf $macroText, $testSet->{input};
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::URLEncode::process($session, $testSet->{input});
is($output, $testSet->{output}, 'testing '.$testSet->{input});
}
-
-END {
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
-}
diff --git a/t/Macro/User.t b/t/Macro/User.t
index 752382e6b..1853ca5be 100644
--- a/t/Macro/User.t
+++ b/t/Macro/User.t
@@ -13,18 +13,14 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::User;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use WebGUI::User;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'User', 'User');
-
my @testSets = (
{
firstName => 'Joe',
@@ -60,18 +56,16 @@ foreach my $testSet (@testSets) {
$session->user({ userId => $testSet->{user}->userId });
foreach my $field (keys %{ $testSet }) {
next if $field eq 'user';
- my $output = sprintf q!^User("%s");!, $field;
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::User::process($session, $field);
my $comment = sprintf "Checking userid: %s, field: %s", $session->user->userId, $field;
is($output, $testSet->{$field}, $comment);
}
}
my $field = "NonExistantField";
-my $output = sprintf q!^User("%s")!, $field;
-WebGUI::Macro::process($session, \$output);
+my $output = WebGUI::Macro::User::process($session, $field);
my $comment = sprintf "Checking userid: %s, field: %s", $session->user->userId, $field;
-is($output, $output, $comment); ##Unprocessed macro returns macro
+is($output, undef, $comment); ##Unprocessed macro returns macro
sub setupTest {
my ($session, @testSets) = @_;
@@ -89,8 +83,4 @@ END { ##Clean-up after yourself, always
foreach my $dude (@users) {
$dude->delete if (defined $dude and ref $dude eq 'WebGUI::User');
}
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/a_account.t b/t/Macro/a_account.t
index 86d463cba..5380f7d64 100644
--- a/t/Macro/a_account.t
+++ b/t/Macro/a_account.t
@@ -13,9 +13,8 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
-use WebGUI::Macro;
+use WebGUI::Macro::a_account;
use WebGUI::Session;
-use WebGUI::Macro_Config;
use HTML::TokeParser;
use Data::Dumper;
@@ -23,9 +22,6 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
-my @added_macros = ();
-push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'a', 'a_account');
-
#
my ($versionTag, $template) = addTemplate();
@@ -37,14 +33,12 @@ my $i18n = WebGUI::International->new($session,'Macro_a_account');
my @testSets = (
{
- macroText => q!^a("%s");!,
label => q!linkonly!,
template => q!!,
output => $session->url->append($homeAsset->getUrl(),'op=auth;method=init'),
comment => 'linkonly argument',
},
{
- macroText => q!^a();!,
label => $i18n->get(46),
template => q!!,
url => $session->url->page('op=auth;method=init'), ##already validated URL above
@@ -52,7 +46,6 @@ my @testSets = (
comment => 'default macro call',
},
{
- macroText => q!^a("%s");!,
label => q!This is your account!,
template => q!!,
url => $session->url->page('op=auth;method=init'),
@@ -60,7 +53,6 @@ my @testSets = (
comment => 'custom label',
},
{
- macroText => q!^a("%s","%s");!,
label => q!Custom label!,
template => $template->get('url'),
url => $session->url->page('op=auth;method=init'),
@@ -77,8 +69,8 @@ foreach my $testSet (@testSets) {
plan tests => $numTests;
foreach my $testSet (@testSets) {
- my $output = sprintf $testSet->{macroText}, $testSet->{label}, $testSet->{template};
- WebGUI::Macro::process($session, \$output);
+ my $output = WebGUI::Macro::a_account::process( $session,
+ $testSet->{label}, $testSet->{template} );
if (ref $testSet->{output} eq 'CODE') {
my ($url, $label) = $testSet->{output}->($output);
is($label, $testSet->{label}, $testSet->{comment}.", label");
@@ -131,8 +123,4 @@ END {
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
$versionTag->rollback;
}
- foreach my $macro (@added_macros) {
- next unless $macro;
- $session->config->deleteFromHash("macros", $macro);
- }
}
diff --git a/t/Macro/c_companyName.t b/t/Macro/c_companyName.t
new file mode 100644
index 000000000..c2e80d39f
--- /dev/null
+++ b/t/Macro/c_companyName.t
@@ -0,0 +1,29 @@
+#-------------------------------------------------------------------
+# WebGUI is Copyright 2001-2006 Plain Black Corporation.
+#-------------------------------------------------------------------
+# Please read the legal notices (docs/legal.txt) and the license
+# (docs/license.txt) that came with this distribution before using
+# this software.
+#-------------------------------------------------------------------
+# http://www.plainblack.com info@plainblack.com
+#-------------------------------------------------------------------
+
+use FindBin;
+use strict;
+use lib "$FindBin::Bin/../lib";
+
+use WebGUI::Test;
+use WebGUI::Macro::c_companyName;
+use WebGUI::Session;
+use Data::Dumper;
+
+use Test::More; # increment this value for each test you create
+
+my $session = WebGUI::Test->session;
+
+plan tests => 1;
+
+my ($value) = $session->dbSlave->quickArray(
+ "select value from settings where name='companyName'");
+my $output = WebGUI::Macro::c_companyName::process($session);
+is($output, $value, sprintf "Testing companyName");
diff --git a/t/Macro/u_companyUrl.t b/t/Macro/u_companyUrl.t
new file mode 100644
index 000000000..bd2b55b99
--- /dev/null
+++ b/t/Macro/u_companyUrl.t
@@ -0,0 +1,29 @@
+#-------------------------------------------------------------------
+# WebGUI is Copyright 2001-2006 Plain Black Corporation.
+#-------------------------------------------------------------------
+# Please read the legal notices (docs/legal.txt) and the license
+# (docs/license.txt) that came with this distribution before using
+# this software.
+#-------------------------------------------------------------------
+# http://www.plainblack.com info@plainblack.com
+#-------------------------------------------------------------------
+
+use FindBin;
+use strict;
+use lib "$FindBin::Bin/../lib";
+
+use WebGUI::Test;
+use WebGUI::Macro::u_companyUrl;
+use WebGUI::Session;
+use Data::Dumper;
+
+use Test::More; # increment this value for each test you create
+
+my $session = WebGUI::Test->session;
+
+plan tests => 1;
+
+my ($value) = $session->dbSlave->quickArray(
+ "select value from settings where name='companyUrl'");
+my $output = WebGUI::Macro::u_companyUrl::process($session);
+is($output, $value, sprintf "Testing companyUrl");