webgui/t/Macro/Extras.t
2006-07-04 04:39:04 +00:00

61 lines
1.8 KiB
Perl

#-------------------------------------------------------------------
# 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;
use WebGUI::Session;
use WebGUI::Macro_Config;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
unless ($session->config->get('macros')->{'Extras'}) {
Macro_Config::insert_macro($session, 'Extras', 'Extras');
}
my @testSets = (
{ ##Just get the extras path
macroText => q!^Extras();!,
path => q!!,
output => $session->url->extras(),
},
{ ##Note that trailing slash is appended
macroText => q!^Extras();!,
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'),
},
{ ##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'),
},
);
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);
}