Line 0
Link Here
|
0 |
- |
1 |
# Copyright 2018 Koha Development Team |
|
|
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 <http://www.gnu.org/licenses>. |
17 |
|
18 |
use Modern::Perl; |
19 |
use Test::More tests => 1; |
20 |
use t::lib::QA::TemplateFilters; |
21 |
|
22 |
my $input = <<INPUT; |
23 |
[% USE Asset %] |
24 |
[% INCLUDE 'doc-head-open.inc' %] |
25 |
<title>Koha › Patrons › |
26 |
[% UNLESS blocking_error %] |
27 |
Patron details for [% INCLUDE 'patron-title.inc' no_html = 1 %] |
28 |
[% just_a_var %] A N D [% another_one_on_same_line %] |
29 |
[% just_a_var_filtered|html %] |
30 |
[% just_a_var_filtered |html %] |
31 |
[% just_a_var_filtered| html %] |
32 |
[% just_a_var_filtered | html %] |
33 |
[% END %] |
34 |
[% IF ( patron.othernames | html ) %]“[% patron.othernames %]”[% END %] |
35 |
[% Asset.css("css/datatables.css").raw %] |
36 |
[% Asset.css("css/datatables.css") | \$raw %] |
37 |
</title> |
38 |
<a href="tel:[% patron.phone %]">[% patron.phone %]</a> |
39 |
<a title="[% patron.emailpro %]" href="mailto:[% patron.emailpro | uri %]">[% patron.emailpro %]</a> |
40 |
[% patron_message.get_column('manager_surname') %] |
41 |
[%# do_nothing %] |
42 |
[% # do_nothing %] |
43 |
[% SWITCH var %] |
44 |
[% CASE 'foo' %]foo |
45 |
[% CASE %] |
46 |
[% END %] |
47 |
[%- SWITCH var -%] |
48 |
[%- CASE 'foo' -%]foo |
49 |
[%- CASE -%] |
50 |
[%- END -%] |
51 |
[%- var -%] |
52 |
[% - var - %] |
53 |
[%~ var ~%] |
54 |
[% ~ var ~ %] |
55 |
[% var | \$raw %] |
56 |
[% foo UNLESS bar %] |
57 |
[% SET var = val %] |
58 |
[% var = val %] |
59 |
[%END%] |
60 |
INPUT |
61 |
|
62 |
my @expected_errors = ( |
63 |
{ |
64 |
error => q{missing_filter}, |
65 |
line => q{ [% just_a_var %] A N D [% another_one_on_same_line %]}, |
66 |
}, |
67 |
{ |
68 |
error => q{missing_filter}, |
69 |
line => q{ [% just_a_var %] A N D [% another_one_on_same_line %]}, |
70 |
}, |
71 |
{ |
72 |
error => q{missing_filter}, |
73 |
line => q{ [% IF ( patron.othernames | html ) %]“[% patron.othernames %]”[% END %]}, |
74 |
}, |
75 |
{ |
76 |
error => q{asset_must_be_raw}, |
77 |
line => q{ [% Asset.css("css/datatables.css").raw %]}, |
78 |
}, |
79 |
{ |
80 |
error => q{missing_filter}, |
81 |
line => q{<a href="tel:[% patron.phone %]">[% patron.phone %]</a>}, |
82 |
}, |
83 |
{ |
84 |
error => q{missing_filter}, |
85 |
line => q{<a href="tel:[% patron.phone %]">[% patron.phone %]</a>}, |
86 |
}, |
87 |
{ |
88 |
error => q{missing_filter}, |
89 |
line => q{<a title="[% patron.emailpro %]" href="mailto:[% patron.emailpro | uri %]">[% patron.emailpro %]</a>}, |
90 |
}, |
91 |
{ |
92 |
error => q{missing_filter}, |
93 |
line => q{<a title="[% patron.emailpro %]" href="mailto:[% patron.emailpro | uri %]">[% patron.emailpro %]</a>}, |
94 |
}, |
95 |
{ |
96 |
error => q{missing_filter}, |
97 |
line => q{[% patron_message.get_column('manager_surname') %]}, |
98 |
}, |
99 |
{ |
100 |
error => q{missing_filter}, |
101 |
line => q{[%- var -%]}, |
102 |
}, |
103 |
{ |
104 |
error => q{missing_filter}, |
105 |
line => q{[% - var - %]}, |
106 |
}, |
107 |
{ |
108 |
error => q{missing_filter}, |
109 |
line => q{[%~ var ~%]}, |
110 |
}, |
111 |
{ |
112 |
error => q{missing_filter}, |
113 |
line => q{[% ~ var ~ %]}, |
114 |
} |
115 |
); |
116 |
|
117 |
my @get = t::lib::QA::TemplateFilters::missing_filters($input); |
118 |
is_deeply( \@get, \@expected_errors); |