Bug 21393: Add tests
Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
54e2f2b5b2
commit
3ad96419a7
1 changed files with 118 additions and 0 deletions
118
t/template_filters.t
Normal file
118
t/template_filters.t
Normal file
|
@ -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 <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
use Test::More tests => 1;
|
||||
use t::lib::QA::TemplateFilters;
|
||||
|
||||
my $input = <<INPUT;
|
||||
[% USE Asset %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>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 %]
|
||||
</title>
|
||||
<a href="tel:[% patron.phone %]">[% patron.phone %]</a>
|
||||
<a title="[% patron.emailpro %]" href="mailto:[% patron.emailpro | uri %]">[% patron.emailpro %]</a>
|
||||
[% 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{<a href="tel:[% patron.phone %]">[% patron.phone %]</a>},
|
||||
},
|
||||
{
|
||||
error => q{missing_filter},
|
||||
line => q{<a href="tel:[% patron.phone %]">[% patron.phone %]</a>},
|
||||
},
|
||||
{
|
||||
error => q{missing_filter},
|
||||
line => q{<a title="[% patron.emailpro %]" href="mailto:[% patron.emailpro | uri %]">[% patron.emailpro %]</a>},
|
||||
},
|
||||
{
|
||||
error => q{missing_filter},
|
||||
line => q{<a title="[% patron.emailpro %]" href="mailto:[% patron.emailpro | uri %]">[% patron.emailpro %]</a>},
|
||||
},
|
||||
{
|
||||
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);
|
Loading…
Reference in a new issue