From ce991215e6d39fa8d4647b476ec93420a770eff0 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 18 Nov 2005 18:36:14 +0000 Subject: [PATCH] default template existance and mandatory template variable checker. Only checks 1 template --- t/mandatory_template_vars.t | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 t/mandatory_template_vars.t diff --git a/t/mandatory_template_vars.t b/t/mandatory_template_vars.t new file mode 100644 index 000000000..2159c7f0e --- /dev/null +++ b/t/mandatory_template_vars.t @@ -0,0 +1,77 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2005 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 +#------------------------------------------------------------------- + +# ---- BEGIN DO NOT EDIT ---- +use strict; +use lib '../lib'; +use Getopt::Long; +use WebGUI::Session; +use WebGUI::Asset; +use File::Find; +# ---- END DO NOT EDIT ---- + +#The goal of this test is to check that mandatory template +#variables exist in their templates. + +my @tmplVarTable = ( + { + id => 'PBtmpl0000000000000051', + vars => [ qw(profile.form.footer profile.form.header profile.form.hidden) ], + }, +); + +use Test::More; # increment this value for each test you create +my $numTests = 0; + +initialize(); # this line is required + +foreach my $tmpl (@tmplVarTable) { + ++$numTests; #Check for template existance + $numTests += scalar @{ $tmpl->{vars} }; #Check for each mandatory variable +} + +# put your tests here + +plan tests => $numTests; + +diag("planning on $numTests tests"); + +foreach my $tmpl ( @tmplVarTable ) { + my $tmplId = $tmpl->{id}; + my $tmplAsset = WebGUI::Asset->newByDynamicClass($tmplId); + my $tmplExists = is(ref($tmplAsset), 'WebGUI::Asset::Template', "$tmplId exists"); + SKIP: { + skip("$tmplId could not be found", scalar @{ $tmpl->{vars} }) unless $tmplExists; + my $tmplName = $tmplAsset->get('title'); + my $template = $tmplAsset->get('template'); + foreach my $var ( @{ $tmpl->{vars} }) { + ok( $template=~qr/$var/, "Checking for $var in $tmplName, id=$tmplId"); + } + } +} + +cleanup(); # this line is required + +# ---- DO NOT EDIT BELOW THIS LINE ----- + +sub initialize { + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + WebGUI::Session::open("..",$configFile); +} + +sub cleanup { + WebGUI::Session::close(); +} +