Rework all tests to call the Macro's process subroutine directly.

Add RootTitle.t test.
Broke up the SettingMacros.t test into individual tests.
This commit is contained in:
Colin Kuskie 2006-07-26 19:02:22 +00:00
parent 60e9523f7b
commit 6aab9a6eec
32 changed files with 433 additions and 623 deletions

View file

@ -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");