Lines 692-699
subtest 'TranslateNotices' => sub {
Link Here
|
692 |
|
692 |
|
693 |
subtest 'SendQueuedMessages' => sub { |
693 |
subtest 'SendQueuedMessages' => sub { |
694 |
|
694 |
|
695 |
plan tests => 4; |
695 |
plan tests => 6; |
|
|
696 |
|
696 |
t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' ); |
697 |
t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' ); |
|
|
698 |
t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', ''); |
699 |
|
697 |
my $patron = Koha::Patrons->find($borrowernumber); |
700 |
my $patron = Koha::Patrons->find($borrowernumber); |
698 |
$dbh->do(q| |
701 |
$dbh->do(q| |
699 |
INSERT INTO message_queue(borrowernumber, subject, content, message_transport_type, status, letter_code) |
702 |
INSERT INTO message_queue(borrowernumber, subject, content, message_transport_type, status, letter_code) |
Lines 707-717
subtest 'SendQueuedMessages' => sub {
Link Here
|
707 |
$patron->set( { smsalertnumber => '5555555555', sms_provider_id => $sms_pro->id() } )->store; |
710 |
$patron->set( { smsalertnumber => '5555555555', sms_provider_id => $sms_pro->id() } )->store; |
708 |
$message_id = C4::Letters::EnqueueLetter($my_message); #using datas set around line 95 and forward |
711 |
$message_id = C4::Letters::EnqueueLetter($my_message); #using datas set around line 95 and forward |
709 |
C4::Letters::SendQueuedMessages(); |
712 |
C4::Letters::SendQueuedMessages(); |
710 |
my $sms_message_address = $schema->resultset('MessageQueue')->search({ |
713 |
|
|
|
714 |
my $message = $schema->resultset('MessageQueue')->search({ |
711 |
borrowernumber => $borrowernumber, |
715 |
borrowernumber => $borrowernumber, |
712 |
status => 'sent' |
716 |
status => 'sent' |
713 |
})->next()->to_address(); |
717 |
})->next(); |
714 |
is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email when to_address not set' ); |
718 |
|
|
|
719 |
is( $message->to_address(), '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email when to_address not set' ); |
720 |
is( |
721 |
$message->from_address(), |
722 |
'from@example.com', |
723 |
'SendQueuedMessages uses message queue item \"from address\" for SMS by email when EmailSMSSendDriverFromAddress system preference is not set' |
724 |
); |
725 |
|
726 |
$schema->resultset('MessageQueue')->search({borrowernumber => $borrowernumber, status => 'sent'})->delete(); #clear borrower queue |
727 |
|
728 |
t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', 'override@example.com'); |
729 |
|
730 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
731 |
C4::Letters::SendQueuedMessages(); |
732 |
|
733 |
$message = $schema->resultset('MessageQueue')->search({ |
734 |
borrowernumber => $borrowernumber, |
735 |
status => 'sent' |
736 |
})->next(); |
737 |
|
738 |
is( |
739 |
$message->from_address(), |
740 |
'override@example.com', |
741 |
'SendQueuedMessages uses EmailSMSSendDriverFromAddress value for SMS by email when EmailSMSSendDriverFromAddress is set' |
742 |
); |
743 |
|
715 |
$schema->resultset('MessageQueue')->search({borrowernumber => $borrowernumber,status => 'sent'})->delete(); #clear borrower queue |
744 |
$schema->resultset('MessageQueue')->search({borrowernumber => $borrowernumber,status => 'sent'})->delete(); #clear borrower queue |
716 |
$my_message->{to_address} = 'fixme@kidclamp.iswrong'; |
745 |
$my_message->{to_address} = 'fixme@kidclamp.iswrong'; |
717 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
746 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
Lines 723-729
subtest 'SendQueuedMessages' => sub {
Link Here
|
723 |
is ( $number_attempted, 0, 'There were no password reset messages for SendQueuedMessages to attempt.' ); |
752 |
is ( $number_attempted, 0, 'There were no password reset messages for SendQueuedMessages to attempt.' ); |
724 |
|
753 |
|
725 |
C4::Letters::SendQueuedMessages(); |
754 |
C4::Letters::SendQueuedMessages(); |
726 |
$sms_message_address = $schema->resultset('MessageQueue')->search({ |
755 |
my $sms_message_address = $schema->resultset('MessageQueue')->search({ |
727 |
borrowernumber => $borrowernumber, |
756 |
borrowernumber => $borrowernumber, |
728 |
status => 'sent' |
757 |
status => 'sent' |
729 |
})->next()->to_address(); |
758 |
})->next()->to_address(); |
730 |
- |
|
|