Lines 598-605
subtest 'TranslateNotices' => sub {
Link Here
|
598 |
|
598 |
|
599 |
subtest 'SendQueuedMessages' => sub { |
599 |
subtest 'SendQueuedMessages' => sub { |
600 |
|
600 |
|
601 |
plan tests => 4; |
601 |
plan tests => 6; |
|
|
602 |
|
602 |
t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' ); |
603 |
t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' ); |
|
|
604 |
t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', ''); |
605 |
|
603 |
my $patron = Koha::Patrons->find($borrowernumber); |
606 |
my $patron = Koha::Patrons->find($borrowernumber); |
604 |
$dbh->do(q| |
607 |
$dbh->do(q| |
605 |
INSERT INTO message_queue(borrowernumber, subject, content, message_transport_type, status, letter_code) |
608 |
INSERT INTO message_queue(borrowernumber, subject, content, message_transport_type, status, letter_code) |
Lines 613-623
subtest 'SendQueuedMessages' => sub {
Link Here
|
613 |
$patron->set( { smsalertnumber => '5555555555', sms_provider_id => $sms_pro->id() } )->store; |
616 |
$patron->set( { smsalertnumber => '5555555555', sms_provider_id => $sms_pro->id() } )->store; |
614 |
$message_id = C4::Letters::EnqueueLetter($my_message); #using datas set around line 95 and forward |
617 |
$message_id = C4::Letters::EnqueueLetter($my_message); #using datas set around line 95 and forward |
615 |
C4::Letters::SendQueuedMessages(); |
618 |
C4::Letters::SendQueuedMessages(); |
616 |
my $sms_message_address = $schema->resultset('MessageQueue')->search({ |
619 |
|
|
|
620 |
my $message = $schema->resultset('MessageQueue')->search({ |
617 |
borrowernumber => $borrowernumber, |
621 |
borrowernumber => $borrowernumber, |
618 |
status => 'sent' |
622 |
status => 'sent' |
619 |
})->next()->to_address(); |
623 |
})->next(); |
620 |
is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email when to_address not set' ); |
624 |
|
|
|
625 |
is( $message->to_address(), '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email when to_address not set' ); |
626 |
is( |
627 |
$message->from_address(), |
628 |
'from@example.com', |
629 |
'SendQueuedMessages uses message queue item \"from address\" for SMS by email when EmailSMSSendDriverFromAddress system preference is not set' |
630 |
); |
631 |
|
632 |
$schema->resultset('MessageQueue')->search({borrowernumber => $borrowernumber, status => 'sent'})->delete(); #clear borrower queue |
633 |
|
634 |
t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', 'override@example.com'); |
635 |
|
636 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
637 |
C4::Letters::SendQueuedMessages(); |
638 |
|
639 |
$message = $schema->resultset('MessageQueue')->search({ |
640 |
borrowernumber => $borrowernumber, |
641 |
status => 'sent' |
642 |
})->next(); |
643 |
|
644 |
is( |
645 |
$message->from_address(), |
646 |
'override@example.com', |
647 |
'SendQueuedMessages uses EmailSMSSendDriverFromAddress value for SMS by email when EmailSMSSendDriverFromAddress is set' |
648 |
); |
649 |
|
621 |
$schema->resultset('MessageQueue')->search({borrowernumber => $borrowernumber,status => 'sent'})->delete(); #clear borrower queue |
650 |
$schema->resultset('MessageQueue')->search({borrowernumber => $borrowernumber,status => 'sent'})->delete(); #clear borrower queue |
622 |
$my_message->{to_address} = 'fixme@kidclamp.iswrong'; |
651 |
$my_message->{to_address} = 'fixme@kidclamp.iswrong'; |
623 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
652 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
Lines 629-635
subtest 'SendQueuedMessages' => sub {
Link Here
|
629 |
is ( $number_attempted, 0, 'There were no password reset messages for SendQueuedMessages to attempt.' ); |
658 |
is ( $number_attempted, 0, 'There were no password reset messages for SendQueuedMessages to attempt.' ); |
630 |
|
659 |
|
631 |
C4::Letters::SendQueuedMessages(); |
660 |
C4::Letters::SendQueuedMessages(); |
632 |
$sms_message_address = $schema->resultset('MessageQueue')->search({ |
661 |
my $sms_message_address = $schema->resultset('MessageQueue')->search({ |
633 |
borrowernumber => $borrowernumber, |
662 |
borrowernumber => $borrowernumber, |
634 |
status => 'sent' |
663 |
status => 'sent' |
635 |
})->next()->to_address(); |
664 |
})->next()->to_address(); |
636 |
- |
|
|