3 # Copyright (C) 2011 Tamil s.a.r.l.
5 # This file is part of Koha.
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
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.
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.
22 use Test
::More tests
=> 2;
28 my @files_with_directive_in_tag = do {
32 return if $dir =~ /blib/;
33 return unless /\.(tt|inc)$/;
35 my $parser = C4
::TTParser
->new;
36 $parser->build_tokens( $name );
38 while ( my $token = $parser->next_token ) {
39 my $attr = $token->{_attr
};
41 push @lines, $token->{_lc
} if $attr->{'[%'};
43 ($dir) = $dir =~ /koha-tmpl\/(.*)$/;
44 push @files, { name
=> "$dir/$name", lines
=> \
@lines } if @lines;
45 }, ( "./koha-tmpl/opac-tmpl/prog/en",
46 "./koha-tmpl/intranet-tmpl/prog/en" )
52 ok
( !@files_with_directive_in_tag, "TT syntax: not using TT directive within HTML tag" )
55 join( "\n", map { $_->{name
} . ': ' . join(', ', @
{$_->{lines
}})
56 } @files_with_directive_in_tag )
60 my $ttparser = C4
::TTParser
->new();
61 $ttparser->unshift_token($testtoken);
62 my $testtokenagain = C4
::TTParser
::next_token
();
63 is
( $testtoken, $testtokenagain, "Token received same as original put on stack");
72 This test validate Template Toolkit (TT) Koha files.
74 For the time being an unique validation is done: Test if TT files contain TT
75 directive within HTML tag. For example:
79 This kind of constuction MUST be avoided because it break Koha translation
84 From Koha root directory:
86 prove -v xt/tt_valid.t