added a test for template
This commit is contained in:
parent
1ad601c8d9
commit
b1b4e50619
2 changed files with 26 additions and 6 deletions
|
|
@ -177,12 +177,16 @@ sub getEditForm {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getList ( namespace )
|
||||
=head2 getList ( session, namespace )
|
||||
|
||||
Returns a hash reference containing template ids and template names of all the templates in the specified namespace.
|
||||
|
||||
NOTE: This is a class method.
|
||||
|
||||
=head3 session
|
||||
|
||||
A reference to the current session.
|
||||
|
||||
=head3 namespace
|
||||
|
||||
Specify the namespace to build the list for.
|
||||
|
|
@ -227,7 +231,7 @@ sub process {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 processRaw ( template, vars )
|
||||
=head2 processRaw ( session, template, vars )
|
||||
|
||||
Evaluate a template replacing template commands for HTML.
|
||||
|
||||
|
|
|
|||
|
|
@ -12,14 +12,30 @@ use strict;
|
|||
use lib '../../lib';
|
||||
use Getopt::Long;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use Test::More tests => 1; # increment this value for each test you create
|
||||
use WebGUI::Asset::Template;
|
||||
use Test::More tests => 8; # increment this value for each test you create
|
||||
|
||||
my $session = initialize(); # this line is required
|
||||
|
||||
my $importNode = WebGUI::Asset->getImportNode($session);
|
||||
my $template = $importNode->addChild({className=>"WebGUI::Asset::Template", title=>"test", url=>"testingtemplates"});
|
||||
my $list = WebGUI::Asset::Template->getList($session);
|
||||
ok(defined $list, "getList()");
|
||||
my $template = " <tmpl_var variable> <tmpl_if conditional>true</tmpl_if> <tmpl_loop loop>XY</tmpl_loop> ";
|
||||
my %var = (
|
||||
variable=>"AAAAA",
|
||||
conditional=>1,
|
||||
loop=>[{},{},{},{},{}]
|
||||
);
|
||||
my $output = WebGUI::Asset::Template->processRaw($session,$template,\%var);
|
||||
ok($output =~ m/AAAAA/, "processRaw() - variables");
|
||||
ok($output =~ m/true/, "processRaw() - conditionals");
|
||||
ok($output =~ m/XYXYXYXYXY/, "processRaw() - loops");
|
||||
my $importNode = WebGUI::Asset::Template->getImportNode($session);
|
||||
my $template = $importNode->addChild({className=>"WebGUI::Asset::Template", title=>"test", url=>"testingtemplates", template=>$template});
|
||||
ok(defined $template, "creating a template");
|
||||
$output = $template->process(\%var);
|
||||
ok($output =~ m/AAAAA/, "process() - variables");
|
||||
ok($output =~ m/true/, "process() - conditionals");
|
||||
ok($output =~ m/XYXYXYXYXY/, "process() - loops");
|
||||
|
||||
|
||||
cleanup($session); # this line is required
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue