add test for WebGUI::Macro::transform

This commit is contained in:
Graham Knop 2010-08-27 13:20:30 -05:00
parent d3893aec75
commit 1fd17ef320
2 changed files with 30 additions and 4 deletions

View file

@ -257,7 +257,7 @@ The name of the macro called.
The module name for the macro from the config file.
=item originalText
=item originalString
The full original text of the macro call.
@ -299,7 +299,7 @@ sub _transformMacro {
session => $session,
macro => $macro,
macroPackage => $macroPackage,
originalText => $original,
originalString => $original,
parameters => $params,
parameterString => $paramString,
});

View file

@ -43,8 +43,6 @@ foreach my $macro (qw/
}
$session->config->addToHash('macros', "Ex'tras", "Extras");
plan tests => 51;
my $macroText = "CompanyName: ^c;";
my $companyName = $session->setting->get('companyName');
WebGUI::HTML::makeParameterSafe( \$companyName );
@ -337,3 +335,31 @@ is (
'@MacroCall[`1`.` 2`.`3`]:',
'internal spaces are okay'
);
my $macroText = 'before ^VisualMacro("1", 2,); after';
my $macroData;
WebGUI::Macro::transform($session, \$macroText, sub {
$macroData = shift;
return "replace";
});
is (
$macroText,
'before replace after',
'transform replaces macro calls'
);
is_deeply($macroData, {
session => $session,
macro => 'VisualMacro',
macroPackage => 'WebGUI::Macro::VisualMacro',
originalString => '^VisualMacro("1", 2,);',
parameters => [
'1',
' 2',
],
parameterString => '("1", 2,)',
}, 'transform passes sub correct data');
done_testing;