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 <gmc@esilibrary.com>
This commit is contained in:
Galen Charlton 2014-05-19 16:14:28 +00:00
parent 8bc2fb4df6
commit b97e691ef8
1 changed files with 14 additions and 2 deletions

View File

@ -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 ), $_ ) ) {