|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 5 |
# Koha is free software; you can redistribute it and/or modify it |
| 6 |
# under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation; either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# Koha is distributed in the hope that it will be useful, but |
| 11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with Koha; if not, see <https://www.gnu.org/licenses>. |
| 17 |
|
| 18 |
use Modern::Perl; |
| 19 |
use File::Slurp qw( read_file ); |
| 20 |
use Test::More; |
| 21 |
|
| 22 |
use Test::NoWarnings; |
| 23 |
|
| 24 |
use Koha::Devel::Files; |
| 25 |
|
| 26 |
my $dev_files = Koha::Devel::Files->new( { context => 'tidy' } ); |
| 27 |
my @tt_files = $dev_files->ls_tt_files; |
| 28 |
|
| 29 |
plan tests => scalar(@tt_files) + 1; |
| 30 |
|
| 31 |
for my $file (@tt_files) { |
| 32 |
|
| 33 |
my @lines = read_file($file); |
| 34 |
my $fails = 0; |
| 35 |
my ( $in_script, $has_tt_tags, $has_kohaTable ); |
| 36 |
for my $line (@lines) { |
| 37 |
|
| 38 |
$in_script ||= $line =~ m{<script}; |
| 39 |
|
| 40 |
if ( $line =~ m{<\/script>} ) { |
| 41 |
if ( $has_kohaTable && $has_tt_tags ) { |
| 42 |
$fails++; |
| 43 |
} |
| 44 |
$has_kohaTable = 0; |
| 45 |
$has_tt_tags = 0; |
| 46 |
$in_script = 0; |
| 47 |
} |
| 48 |
next unless $in_script; |
| 49 |
|
| 50 |
$has_kohaTable ||= $line =~ m{\).kohaTable\(}; |
| 51 |
|
| 52 |
$has_tt_tags ||= $line =~ m{\[\%.*?\%\]}s; |
| 53 |
} |
| 54 |
|
| 55 |
is( $fails, 0, "$file has 'kohaTable' instances in a <script> tag with Template::Toolkit tags." ); |
| 56 |
} |