Bug 12271: (follow-up) teach valid-templates.t how to include specified templates
authorGalen Charlton <gmc@esilibrary.com>
Mon, 19 May 2014 16:14:28 +0000 (16:14 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 19 May 2014 16:14:28 +0000 (16:14 +0000)
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>

xt/author/valid-templates.t

index c3d0490..e02b6f3 100644 (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 ), $_ ) ) {