From b6e469f6f99c984bb2373f927a81c2a389f89176 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 21 Sep 2018 12:03:05 -0300 Subject: [PATCH] Bug 21393: Add tests Signed-off-by: Josef Moravec --- t/template_filters.t | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 t/template_filters.t diff --git a/t/template_filters.t b/t/template_filters.t new file mode 100644 index 0000000..4131534 --- /dev/null +++ b/t/template_filters.t @@ -0,0 +1,118 @@ +# Copyright 2018 Koha Development Team +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Test::More tests => 1; +use t::lib::QA::TemplateFilters; + +my $input = <Koha › Patrons › + [% UNLESS blocking_error %] + Patron details for [% INCLUDE 'patron-title.inc' no_html = 1 %] + [% just_a_var %] A N D [% another_one_on_same_line %] + [% just_a_var_filtered|html %] + [% just_a_var_filtered |html %] + [% just_a_var_filtered| html %] + [% just_a_var_filtered | html %] + [% END %] + [% IF ( patron.othernames | html ) %]“[% patron.othernames %]”[% END %] + [% Asset.css("css/datatables.css").raw %] + [% Asset.css("css/datatables.css") | \$raw %] + +[% patron.phone %] +[% patron.emailpro %] +[% patron_message.get_column('manager_surname') %] +[%# do_nothing %] +[% # do_nothing %] +[% SWITCH var %] +[% CASE 'foo' %]foo +[% CASE %] +[% END %] +[%- SWITCH var -%] +[%- CASE 'foo' -%]foo +[%- CASE -%] +[%- END -%] +[%- var -%] +[% - var - %] +[%~ var ~%] +[% ~ var ~ %] +[% var | \$raw %] +[% foo UNLESS bar %] +[% SET var = val %] +[% var = val %] +[%END%] +INPUT + +my @expected_errors = ( + { + error => q{missing_filter}, + line => q{ [% just_a_var %] A N D [% another_one_on_same_line %]}, + }, + { + error => q{missing_filter}, + line => q{ [% just_a_var %] A N D [% another_one_on_same_line %]}, + }, + { + error => q{missing_filter}, + line => q{ [% IF ( patron.othernames | html ) %]“[% patron.othernames %]”[% END %]}, + }, + { + error => q{asset_must_be_raw}, + line => q{ [% Asset.css("css/datatables.css").raw %]}, + }, + { + error => q{missing_filter}, + line => q{[% patron.phone %]}, + }, + { + error => q{missing_filter}, + line => q{[% patron.phone %]}, + }, + { + error => q{missing_filter}, + line => q{[% patron.emailpro %]}, + }, + { + error => q{missing_filter}, + line => q{[% patron.emailpro %]}, + }, + { + error => q{missing_filter}, + line => q{[% patron_message.get_column('manager_surname') %]}, + }, + { + error => q{missing_filter}, + line => q{[%- var -%]}, + }, + { + error => q{missing_filter}, + line => q{[% - var - %]}, + }, + { + error => q{missing_filter}, + line => q{[%~ var ~%]}, + }, + { + error => q{missing_filter}, + line => q{[% ~ var ~ %]}, + } +); + +my @get = t::lib::QA::TemplateFilters::missing_filters($input); +is_deeply( \@get, \@expected_errors); -- 2.1.4