From b97e691ef87bf3fd89f38ba0b1772d8fcac44b33 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 19 May 2014 16:14:28 +0000 Subject: [PATCH] Bug 12271: (follow-up) teach valid-templates.t how to include specified templates Two of the template includes in the Bootstrap theme cannot be tested all by themselves because they require that the template that includes them define BLOCKs. This patch ensures that they are excluded from individual testing; they will get exercised sufficiently by being including by all of the other Bootstrap templates. Signed-off-by: Galen Charlton --- xt/author/valid-templates.t | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/xt/author/valid-templates.t b/xt/author/valid-templates.t index c3d0490ec8..e02b6f3b62 100644 --- a/xt/author/valid-templates.t +++ b/xt/author/valid-templates.t @@ -47,7 +47,11 @@ run_template_test( print "Testing opac bootstrap templates\n"; run_template_test( 'koha-tmpl/opac-tmpl/bootstrap/en/modules', - 'koha-tmpl/opac-tmpl/bootstrap/en/includes' + 'koha-tmpl/opac-tmpl/bootstrap/en/includes', + # templates to exclude from testing because + # they cannot stand alone + 'doc-head-close.inc', + 'opac-bottom.inc', ); print "Testing opac prog templates\n"; @@ -63,15 +67,17 @@ done_testing(); sub run_template_test { my $template_path = shift; my $include_path = shift; + my @exclusions = @_; my $template_dir = File::Spec->rel2abs($template_path); my $include_dir = File::Spec->rel2abs($include_path); - my $template_test = create_template_test($include_dir); + my $template_test = create_template_test($include_dir, @exclusions); find( { wanted => $template_test, no_chdir => 1 }, $template_dir, $include_dir ); } sub create_template_test { my $includes = shift; + my @exclusions = @_; return sub { my $tt = Template->new( { @@ -80,6 +86,12 @@ sub create_template_test { PLUGIN_BASE => 'Koha::Template::Plugin', } ); + foreach my $exclusion (@exclusions) { + if ($_ =~ /${exclusion}$/) { + diag("excluding template $_ because it cannot stand on its own"); + return; + } + } my $vars; my $output; if ( !ok( $tt->process( $_, $vars, \$output ), $_ ) ) { -- 2.39.5