3 # This file is part of Koha.
5 # Copyright (C) 2011 Tamil s.a.r.l.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Test
::More tests
=> 2;
30 my $opac_dir = 'koha-tmpl/opac-tmpl';
31 opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!";
32 for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
33 push @themes, "$opac_dir/$theme/en";
38 my $staff_dir = 'koha-tmpl/intranet-tmpl';
39 opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!";
40 for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
41 push @themes, "$staff_dir/$theme/en";
45 my @files_with_directive_in_tag = do {
49 return if $dir =~ /blib/;
50 return unless /\.(tt|inc)$/;
52 my $parser = C4
::TTParser
->new;
53 $parser->build_tokens( $name );
55 while ( my $token = $parser->next_token ) {
56 my $attr = $token->{_attr
};
58 push @lines, $token->{_lc
} if $attr->{'[%'} or $attr->{'[%-'};
60 ($dir) = $dir =~ /koha-tmpl\/(.*)$/;
61 push @files, { name
=> "$dir/$name", lines
=> \
@lines } if @lines;
68 ok
( !@files_with_directive_in_tag, "TT syntax: not using TT directive within HTML tag" )
71 join( "\n", map { $_->{name
} . ': ' . join(', ', @
{$_->{lines
}})
72 } @files_with_directive_in_tag )
76 my $ttparser = C4
::TTParser
->new();
77 $ttparser->unshift_token($testtoken);
78 my $testtokenagain = C4
::TTParser
::next_token
();
79 is
( $testtoken, $testtokenagain, "Token received same as original put on stack");
88 This test validate Template Toolkit (TT) Koha files.
90 For the time being an unique validation is done: Test if TT files contain TT
91 directive within HTML tag. For example:
95 This kind of constuction MUST be avoided because it break Koha translation
100 From Koha root directory:
102 prove -v xt/tt_valid.t