From fb288e12f5a86b5c65d1fa62bc3b823121ded85a Mon Sep 17 00:00:00 2001 From: Indranil Das Gupta Date: Wed, 20 May 2015 01:08:18 +0530 Subject: [PATCH] Bug 14206 Adds two tests to t/db_dependent/Letters.t C4::Letters::getletter is called in tools/letter.pl by the function delete_confirm() to display the selected notice for deletion. Due to current implementation of getletter(), a notice that does not use the 'email' template (but uses any/all of the other templates - sms, print or phone) can't be deleted from the staff client. This patch adds 2 tests to t/db_dependent/Letters.t to test the bug. Test plan ========= 1/ Apply the patch and run prove -v t/db_dependent/Letters.t 2/ Test 38 should pass demonstrating unpatched getletter() behaviour Test 39 should FAIL, highlighting the problem # Failed test 'Bug 14206 - returns actual message_transport_type' # at t/db_dependent/Letters.t line 181. # got: undef # expected: 'print' (Test plan continues in the second commit) --- t/db_dependent/Letters.t | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index f53e75b..b057b75 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 => 58; +use Test::More tests => 60; use Test::MockModule; use Test::Warn; @@ -173,6 +173,12 @@ is( $letter->{title}, $title, 'GetLetters gets the title correctly' ); is( $letter->{content}, $content, 'GetLetters gets the content correctly' ); is( $letter->{message_transport_type}, 'email', 'GetLetters gets the message type correctly' ); +# Regression test for Bug 14206 +$dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES ('CPL','my module','my code','my name',1,?,?,'print')|, undef, $title, $content ); +my $letter14206_a = C4::Letters::getletter('my module', 'my code', 'CPL' ); +is( $letter14206_a->{message_transport_type}, 'email', 'Bug 14206 - returns default message_transport_type' ); +my $letter14206_b = C4::Letters::getletter('my module', 'my code', 'CPL', $mtts ); +is( $letter14206_b->{message_transport_type}, 'print', 'Bug 14206 - returns actual message_transport_type' ); # addalert my $type = 'my type'; -- 1.9.1