From: Moritz Bunkus Date: Tue, 3 Nov 2015 14:25:36 +0000 (+0100) Subject: Test zur Prüfung der Syntax aller Template::Toolkit-Templates X-Git-Tag: release-3.4.1~598 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5dba1d4a26ad134882a22e47e4f3c632a73d4b7a;p=kivitendo-erp.git Test zur Prüfung der Syntax aller Template::Toolkit-Templates --- diff --git a/t/template_syntax.t b/t/template_syntax.t new file mode 100644 index 000000000..b1b4224bf --- /dev/null +++ b/t/template_syntax.t @@ -0,0 +1,40 @@ +use strict; + +use lib 't'; + +use Support::Templates; + +use File::Spec; +use File::Slurp; +use Template; +use Template::Provider; +use Test::More tests => ( scalar(@referenced_files)); + +my $template_path = 'templates/webpages/'; + +my $provider = Template::Provider->new({ + INTERPOLATE => 0, + EVAL_PERL => 0, + ABSOLUTE => 1, + CACHE_SIZE => 0, + PLUGIN_BASE => 'SL::Template::Plugin', + INCLUDE_PATH => '.:' . $template_path, +}); + +foreach my $ref (@Support::Templates::referenced_files) { + my $file = "${template_path}${ref}.html"; + my ($result, $not_ok) = $provider->fetch($file); + + if (!$not_ok) { + ok(1, "${file} does not contain errors"); + + } elsif (ref($result) eq 'Template::Exception') { + print STDERR $result->as_string; + ok(0, "${file} contains syntax errors"); + + } else { + die "Unknown result type: " . ref($result); + } +} + +exit 0;