From 8d4789c2b54ac8a600891bc39f2befbb67ce4b36 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 21 Jan 2017 14:13:36 +0100 Subject: [PATCH] Bug 17970: Add tests to highlight the problem --- t/db_dependent/Letters.t | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index 8219e5b..4395535 100644 --- a/t/db_dependent/Letters.t +++ b/t/db_dependent/Letters.t @@ -47,6 +47,7 @@ use Koha::Acquisition::Order; use Koha::Acquisition::Booksellers; use Koha::Acquisition::Bookseller::Contacts; use Koha::Libraries; +use Koha::Notice::Templates; my $schema = Koha::Database->schema; $schema->storage->txn_begin(); @@ -439,6 +440,44 @@ warning_like { is($err->{'error'}, 'no_letter', "No TESTACQORDER letter was defined."); } +subtest 'GetPreparedLetter' => sub { + plan tests => 2; + + Koha::Notice::Template->new( + { + module => 'test', + code => 'test', + branchcode => '', + message_transport_type => 'email' + } + )->store; + my $letter; + warning_like { + $letter = C4::Letters::GetPreparedLetter( + module => 'test', + letter_code => 'test', + ); + } + qr{^ERROR: nothing to substitute}, +'GetPreparedLetter should warn if tables, substiture and repeat are not set'; + is( $letter, undef, +'No letter should be returned by GetPreparedLetter if something went wrong' + ); + + warning_like { + $letter = C4::Letters::GetPreparedLetter( + module => 'test', + letter_code => 'test', + substitute => {} + ); + } + qr{^ERROR: nothing to substitute}, +'GetPreparedLetter should warn if tables, substiture and repeat are not set, even if the key is passed'; + is( $letter, undef, +'No letter should be returned by GetPreparedLetter if something went wrong' + ); + +}; { warning_is { -- 2.1.4