From 1804ac8c6e0ced181fb935fd5b601b4a0cb21c6c Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 4 Jul 2006 04:39:04 +0000 Subject: [PATCH] basic tests for Extras macro --- t/Macro/Extras.t | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 t/Macro/Extras.t diff --git a/t/Macro/Extras.t b/t/Macro/Extras.t new file mode 100644 index 000000000..66e51c3d5 --- /dev/null +++ b/t/Macro/Extras.t @@ -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); +} +