|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# Copyright (C) 2011 Tamil s.a.r.l. |
| 4 |
# |
| 5 |
# This file is part of Koha. |
| 6 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it under the |
| 8 |
# terms of the GNU General Public License as published by the Free Software |
| 9 |
# Foundation; either version 2 of the License, or (at your option) any later |
| 10 |
# version. |
| 11 |
# |
| 12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
| 14 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License along |
| 17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
| 18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
|
| 20 |
use warnings; |
| 21 |
use strict; |
| 22 |
use Test::More tests => 1; |
| 23 |
use File::Find; |
| 24 |
use Cwd; |
| 25 |
|
| 26 |
|
| 27 |
my @files_with_directive_in_tag = do { |
| 28 |
my @files; |
| 29 |
find( sub { |
| 30 |
my $dir = getcwd(); |
| 31 |
return if $dir =~ /blib/; |
| 32 |
return unless /\.(tt)$/; |
| 33 |
open my $fh, "<", $_; |
| 34 |
my $name = $_; |
| 35 |
my $line = 1; |
| 36 |
my @lines; |
| 37 |
while ( <$fh> ) { |
| 38 |
push @lines, $line if /<([a-z]*)\s*\[/i; |
| 39 |
$line++; |
| 40 |
} |
| 41 |
($dir) = $dir =~ /koha-tmpl\/(.*)$/; |
| 42 |
push @files, { name => "$dir/$name", lines => \@lines } if @lines; |
| 43 |
}, ( './koha-tmpl/opac-tmpl/prog/en', './koha-tmpl/intranet-tmpl/prog/en' ) ); |
| 44 |
@files; |
| 45 |
}; |
| 46 |
|
| 47 |
|
| 48 |
ok( !@files_with_directive_in_tag, "TT syntax: not using TT directive within HTML tag" ) |
| 49 |
or diag( "Files list: \n", |
| 50 |
join( "\n", map {$_->{name} . ': ' . join(', ', @{$_->{lines}}) |
| 51 |
} @files_with_directive_in_tag ) ); |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
=head1 NAME |
| 56 |
|
| 57 |
tt_valid.t |
| 58 |
|
| 59 |
=head1 DESCRIPTION |
| 60 |
|
| 61 |
This test validate Template Toolkit (TT) Koha files. |
| 62 |
|
| 63 |
For the time being an unique validation is done: Test if TT files contain TT |
| 64 |
directive within HTML tag. For example: |
| 65 |
|
| 66 |
<li[% IF |
| 67 |
|
| 68 |
This kind of constuction MUST be avoided because it break Koha translation |
| 69 |
process. |
| 70 |
|
| 71 |
=head1 USAGE |
| 72 |
|
| 73 |
From Koha root directory: |
| 74 |
|
| 75 |
prove -v xt/tt_valid.t |
| 76 |
|
| 77 |
=cut |
| 78 |
|