# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
-use Test::More tests => 77;
+use Test::More tests => 76;
use Test::MockModule;
use Test::Warn;
$dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,'my module','my code','my name',1,?,?,'email')|, undef, $library->{branchcode}, $title, $content );
$letters = C4::Letters::GetLetters();
is( @$letters, 1, 'GetLetters returns the correct number of letters' );
-is( $letters->[0]->{branchcode}, $library->{branchcode}, 'GetLetters gets the branch code correctly' );
is( $letters->[0]->{module}, 'my module', 'GetLetters gets the module correctly' );
is( $letters->[0]->{code}, 'my code', 'GetLetters gets the code correctly' );
is( $letters->[0]->{name}, 'my name', 'GetLetters gets the name correctly' );
subtest 'SendQueuedMessages' => sub {
- plan tests => 2;
+ plan tests => 3;
t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' );
my $patron = Koha::Patrons->find($borrowernumber);
$dbh->do(q|
borrowernumber => $borrowernumber,
status => 'sent'
})->next()->to_address();
- is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email' );
+ is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email when to_address not set' );
+ $schema->resultset('MessageQueue')->search({borrowernumber => $borrowernumber,status => 'sent'})->delete(); #clear borrower queue
+ $my_message->{to_address} = 'fixme@kidclamp.iswrong';
+ $message_id = C4::Letters::EnqueueLetter($my_message);
+ C4::Letters::SendQueuedMessages();
+ $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 when to_address is set incorrectly' );
+
};
subtest 'get_item_content' => sub {