basic tests for Extras macro
This commit is contained in:
parent
553f1e0c4a
commit
1804ac8c6e
1 changed files with 61 additions and 0 deletions
61
t/Macro/Extras.t
Normal file
61
t/Macro/Extras.t
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue