From 8f726ae06d05951bb33540d122a47f1637b39f20 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 23 May 2017 16:11:06 -0400 Subject: [PATCH] Bug 18478 - QA Followup Make sure to build necessary letters Fix awkward construction Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- C4/Letters.pm | 2 +- t/db_dependent/Reserves.t | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index e0aaafe042..cd7b785c96 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1054,7 +1054,7 @@ sub SendQueuedMessages { _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } ); next MESSAGE; } - $message->{to_address} = $message->{to_address} ? $message->{to_address} : $member->{'smsalertnumber'}; + $message->{to_address} ||= $member->{'smsalertnumber'}; unless ( $message->{to_address} && $member->{'smsalertnumber'} ) { _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } ); warn sprintf( "No smsalertnumber found for patron %s!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug; diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 0ac07f3f4a..1a2d33c80b 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -733,14 +733,30 @@ subtest '_koha_notify_reserve() tests' => sub { }; my $mp = Test::MockModule->new( 'C4::Members::Messaging' ); + $mp->mock("GetMessagingPreferences",$wants_hold_and_email); - my $sms_hold_notice = $builder->build_object({ - class => 'Koha::Notice::Templates', + $dbh->do('DELETE FROM letter'); + + my $email_hold_notice = $builder->build({ + source => 'Letter', + value => { + message_transport_type => 'email', + branchcode => '', + code => 'HOLD', + module => 'reserves', + lang => 'default', + } + }); + + my $sms_hold_notice = $builder->build({ + source => 'Letter', value => { message_transport_type => 'sms', branchcode => '', code => 'HOLD', + module => 'reserves', + lang=>'default', } }); -- 2.39.5