From 056b895223fff8454407f249f496321a9e291874 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 17 May 2017 12:58:09 -0400 Subject: [PATCH] Bug 18478 - Unit tests Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- t/db_dependent/Letters.t | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index 88ff567229..326227f0e6 100644 --- a/t/db_dependent/Letters.t +++ b/t/db_dependent/Letters.t @@ -91,7 +91,7 @@ is( C4::Letters::EnqueueLetter(), undef, 'EnqueueLetter without argument returns my $my_message = { borrowernumber => $borrowernumber, message_transport_type => 'sms', - to_address => 'to@example.com', + to_address => undef, from_address => 'from@example.com', }; my $message_id = C4::Letters::EnqueueLetter($my_message); @@ -493,7 +493,8 @@ is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial } subtest 'SendQueuedMessages' => sub { - plan tests => 1; + + plan tests => 2; t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' ); my $patron = Koha::Patrons->find($borrowernumber); $dbh->do(q| @@ -503,4 +504,15 @@ subtest 'SendQueuedMessages' => sub { ); eval { C4::Letters::SendQueuedMessages(); }; is( $@, '', 'SendQueuedMessages should not explode if the patron does not have a sms provider set' ); + + my $sms_pro = $builder->build({ source => 'SmsProvider', value => { domain => 'kidclamp.rocks' } }); + ModMember( borrowernumber => $borrowernumber, smsalertnumber => '5555555555', sms_provider_id => $sms_pro->{id} ); + $message_id = C4::Letters::EnqueueLetter($my_message); #using datas set around line 95 and forward + C4::Letters::SendQueuedMessages(); + my $sms_message_address = $schema->resultset('MessageQueue')->search({ + borrowernumber => $borrowernumber, + status => 'sent' + })->next()->to_address(); + is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email' ); + }; -- 2.39.5