From dbe060ff6b8309840ad08924f41bdc2301fc8710 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 25 Sep 2008 22:57:15 +0000 Subject: [PATCH] add a CODE_COP test to make sure that default templates always use the gateway macro with parens --- t/templateChecker.t | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 t/templateChecker.t diff --git a/t/templateChecker.t b/t/templateChecker.t new file mode 100644 index 000000000..8461ac704 --- /dev/null +++ b/t/templateChecker.t @@ -0,0 +1,64 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2007 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 warnings; +use lib "$FindBin::Bin/lib"; ##t/lib + +use WebGUI::Test; +use WebGUI::Operation::Help; +use WebGUI::International; +use WebGUI::Session; +use Data::Dumper; +use WebGUI::Asset::Template; + +#The goal of this test is to locate poorly used macros in the default +#templates; + +use Test::More; # increment this value for each test you create +my $numTests = 0; +plan skip_all => 'set CODE_COP to enable this test' unless $ENV{CODE_COP}; + +my $session = WebGUI::Test->session; +my $lib = WebGUI::Test->lib; + +##Find the name of the International macro in the user's config file. + +#diag "International macro name = $international"; + +##Regexp setup for parsing out the Macro calls. +my $macro = qr{ + \^ + / + ; + }xms; + +# put your tests here + +$numTests = $session->db->quickScalar('select count(distinct(assetId)) from template'); + +plan tests => $numTests; + +my $getATemplate = WebGUI::Asset::Template->getIsa($session); + +my @templateLabels; + +while (my $templateAsset = $getATemplate->()) { + my $template = $templateAsset->get('template'); + my $header = $templateAsset->get('headBlock'); + my $match = ($template =~ $macro); + if ($header) { + $match ||= ($header =~ $macro); + } + ok(!$match, sprintf "%s: (%s) has no bad gateway macros", $templateAsset->getTitle, $templateAsset->getId); +} + +