From bebc0acf8f17cbfa296b517ef60a621a75869351 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 6 Mar 2014 16:59:44 -0500 Subject: [PATCH] Bug 8000 - Missing test to trigger code change This adds a test case which will trigger _send_message_by_email and thus provide a way to run the changes made. --- t/db_dependent/Letters.t | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index 7738359..653508f 100644 --- a/t/db_dependent/Letters.t +++ b/t/db_dependent/Letters.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use C4::Context; use C4::Letters; @@ -40,6 +40,7 @@ my $borrowernumber = AddMember( branchcode => 'CPL', ); +# used to trigger _send_message_by_sms in C4::Letter my $message_id = C4::Letters::EnqueueLetter({ borrowernumber => $borrowernumber, message_transport_type => 'sms', @@ -54,13 +55,29 @@ my $message_id = C4::Letters::EnqueueLetter({ }, }); -ok(defined $message_id && $message_id > 0, 'new message successfully queued'); +# used to trigger _send_message_by_email in C4::Letter +my $message_id2 = C4::Letters::EnqueueLetter({ + borrowernumber => $borrowernumber, + message_transport_type => 'email', + to_address => 'to@example.com', + from_address => 'from@example.com', + letter => { + content => 'a message', + title => 'message title', + metadata => 'metadata', + code => 'TEST_MESSAGE', + content_type => 'text/plain', + }, +}); + +ok(defined $message_id && $message_id > 0, 'new message successfully queued'); +ok(defined $message_id2 && $message_id2 > 0, 'new message successfully queued'); my $messages_processed = C4::Letters::SendQueuedMessages(); -is($messages_processed, 1, 'all queued messages processed'); +is($messages_processed, 2, 'all queued messages processed'); my $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); -is(scalar(@$messages), 1, 'one message stored for the borrower'); +is(scalar(@$messages), 2, 'two messages stored for the borrower'); is( $messages->[0]->{status}, -- 1.7.10.4