Bug 26734: (QA follow-up) Unit tests for C4::Letters

This patch adds unit tests for the addition of 'include handling' to the
C4::Letters template toolkit functionality.

Test plan
1/ Run t/db_dependant/Letters/TemplateToolkit.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Martin Renvoize 2021-03-12 13:50:14 +00:00 committed by Jonathan Druart
parent 1a74852018
commit d9a508a499

View file

@ -19,7 +19,7 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 27;
use Test::More tests => 28;
use Test::MockModule;
use Test::Warn;
@ -1082,6 +1082,28 @@ subtest 'add_tt_filters' => sub {
is( $letter->{content}, $expected_letter, "Pre-processing should call TT plugin to remove punctuation if table is biblio or biblioitems");
};
subtest 'Handle includes' => sub {
plan tests => 1;
my $cgi = CGI->new();
my $code = 'TEST_INCLUDE';
my $account =
$builder->build_object( { class => 'Koha::Account::Lines', value => { credit_type_code => 'PAYMENT', status => 'CANCELLED' } } );
my $template = <<EOF;
[%- USE Price -%]
[%- PROCESS 'accounts.inc' -%]
[%- PROCESS account_type_description account=credit -%]
EOF
reset_template({ template => $template, code => $code, module => 'test' });
my $letter = GetPreparedLetter(
module => 'test',
letter_code => $code,
tables => {
credits => $account->accountlines_id
}
);
is($letter->{content},' <span>Payment<span> (Cancelled)</span> </span>', "Include used in notice");
};
subtest 'Dates formatting' => sub {
plan tests => 1;
my $code = 'TEST_DATE';