From d21442337206d46cfe690310b0773a8fde880cc2 Mon Sep 17 00:00:00 2001 From: Indranil Das Gupta Date: Thu, 21 May 2015 06:41:46 +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 FAIL - getletter() fails when message_transport_type is not passed by caller function i.e. delete_confirm() in letter.pl # Failed test 'Bug 14206 - message_transport_type not passed, correct mtt detected' # at t/db_dependent/Letters.t line 179. # got: undef # expected: 'print' Test 39 should pass - getletter() functions correctly when passed message_transport_type param by caller function i.e. add_validate() (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..6ac9f58 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 ('FFL','my module','my code','my name',1,?,?,'print')|, undef, $title, $content ); +my $letter14206_a = C4::Letters::getletter('my module', 'my code', 'FFL' ); +is( $letter14206_a->{message_transport_type}, 'print', 'Bug 14206 - message_transport_type not passed, correct mtt detected' ); +my $letter14206_b = C4::Letters::getletter('my module', 'my code', 'FFL', 'print'); +is( $letter14206_b->{message_transport_type}, 'print', 'Bug 14206 - message_transport_type passed, correct mtt detected' ); # addalert my $type = 'my type'; -- 1.9.1