From 00cf59d33e433287718f3dd5bb895d744bdf0d03 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 Content-Type: text/plain; charset=utf-8 Signed-off-by: Mark Tompsett Signed-off-by: Marcel de Rooy --- t/db_dependent/Letters.t | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index 8219e5b..cb8e6ca 100644 --- a/t/db_dependent/Letters.t +++ b/t/db_dependent/Letters.t @@ -18,7 +18,7 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 79; +use Test::More tests => 80; use Test::MockModule; use Test::Warn; @@ -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 => 4; + + 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