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,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});
}