|
Lines 18-24
Link Here
|
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
use Test::More tests => 82; |
21 |
use Test::More tests => 83; |
| 22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
|
24 |
|
|
Lines 109-114
$my_message->{letter} = {
Link Here
|
| 109 |
code => 'TEST_MESSAGE', |
109 |
code => 'TEST_MESSAGE', |
| 110 |
content_type => 'text/plain', |
110 |
content_type => 'text/plain', |
| 111 |
}; |
111 |
}; |
|
|
112 |
|
| 112 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
113 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
| 113 |
is( $message_id, undef, 'EnqueueLetter without the message type argument argument returns undef' ); |
114 |
is( $message_id, undef, 'EnqueueLetter without the message type argument argument returns undef' ); |
| 114 |
|
115 |
|
|
Lines 628-630
subtest 'SendQueuedMessages' => sub {
Link Here
|
| 628 |
is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email' ); |
629 |
is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email' ); |
| 629 |
|
630 |
|
| 630 |
}; |
631 |
}; |
| 631 |
- |
632 |
|
|
|
633 |
subtest 'Test limit parameter for SendQueuedMessages' => sub { |
| 634 |
plan tests => 3; |
| 635 |
|
| 636 |
my $dbh = C4::Context->dbh; |
| 637 |
|
| 638 |
my $borrowernumber = AddMember( |
| 639 |
firstname => 'Jane', |
| 640 |
surname => 'Smith', |
| 641 |
categorycode => $patron_category, |
| 642 |
branchcode => $library->{branchcode}, |
| 643 |
dateofbirth => $date, |
| 644 |
smsalertnumber => undef, |
| 645 |
); |
| 646 |
|
| 647 |
$dbh->do(q|DELETE FROM message_queue|); |
| 648 |
$my_message = { |
| 649 |
'letter' => { |
| 650 |
'content' => 'a message', |
| 651 |
'metadata' => 'metadata', |
| 652 |
'code' => 'TEST_MESSAGE', |
| 653 |
'content_type' => 'text/plain', |
| 654 |
'title' => 'message title' |
| 655 |
}, |
| 656 |
'borrowernumber' => $borrowernumber, |
| 657 |
'to_address' => undef, |
| 658 |
'message_transport_type' => 'sms', |
| 659 |
'from_address' => 'from@example.com' |
| 660 |
}; |
| 661 |
C4::Letters::EnqueueLetter($my_message); |
| 662 |
C4::Letters::EnqueueLetter($my_message); |
| 663 |
C4::Letters::EnqueueLetter($my_message); |
| 664 |
C4::Letters::EnqueueLetter($my_message); |
| 665 |
C4::Letters::EnqueueLetter($my_message); |
| 666 |
my $messages_processed = C4::Letters::SendQueuedMessages( { limit => 1 } ); |
| 667 |
is( $messages_processed, 1, |
| 668 |
'Processed 1 message with limit of 1 and 5 unprocessed messages' ); |
| 669 |
$messages_processed = C4::Letters::SendQueuedMessages( { limit => 2 } ); |
| 670 |
is( $messages_processed, 2, |
| 671 |
'Processed 2 message with limit of 2 and 4 unprocessed messages' ); |
| 672 |
$messages_processed = C4::Letters::SendQueuedMessages( { limit => 3 } ); |
| 673 |
is( $messages_processed, 2, |
| 674 |
'Processed 2 message with limit of 3 and 2 unprocessed messages' ); |
| 675 |
}; |