|
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 => 76; |
21 |
use Test::More tests => 77; |
| 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 688-690
EOF
Link Here
|
| 688 |
EOF |
689 |
EOF |
| 689 |
is( $items_content, $expected_items_content, 'get_item_content should return correct items info without time (if dateonly => 1)' ); |
690 |
is( $items_content, $expected_items_content, 'get_item_content should return correct items info without time (if dateonly => 1)' ); |
| 690 |
}; |
691 |
}; |
| 691 |
- |
692 |
|
|
|
693 |
subtest 'Test limit parameter for SendQueuedMessages' => sub { |
| 694 |
plan tests => 3; |
| 695 |
|
| 696 |
my $dbh = C4::Context->dbh; |
| 697 |
|
| 698 |
my $borrowernumber = AddMember( |
| 699 |
firstname => 'Jane', |
| 700 |
surname => 'Smith', |
| 701 |
categorycode => $patron_category, |
| 702 |
branchcode => $library->{branchcode}, |
| 703 |
dateofbirth => $date, |
| 704 |
smsalertnumber => undef, |
| 705 |
); |
| 706 |
|
| 707 |
$dbh->do(q|DELETE FROM message_queue|); |
| 708 |
$my_message = { |
| 709 |
'letter' => { |
| 710 |
'content' => 'a message', |
| 711 |
'metadata' => 'metadata', |
| 712 |
'code' => 'TEST_MESSAGE', |
| 713 |
'content_type' => 'text/plain', |
| 714 |
'title' => 'message title' |
| 715 |
}, |
| 716 |
'borrowernumber' => $borrowernumber, |
| 717 |
'to_address' => undef, |
| 718 |
'message_transport_type' => 'sms', |
| 719 |
'from_address' => 'from@example.com' |
| 720 |
}; |
| 721 |
C4::Letters::EnqueueLetter($my_message); |
| 722 |
C4::Letters::EnqueueLetter($my_message); |
| 723 |
C4::Letters::EnqueueLetter($my_message); |
| 724 |
C4::Letters::EnqueueLetter($my_message); |
| 725 |
C4::Letters::EnqueueLetter($my_message); |
| 726 |
my $messages_processed = C4::Letters::SendQueuedMessages( { limit => 1 } ); |
| 727 |
is( $messages_processed, 1, |
| 728 |
'Processed 1 message with limit of 1 and 5 unprocessed messages' ); |
| 729 |
$messages_processed = C4::Letters::SendQueuedMessages( { limit => 2 } ); |
| 730 |
is( $messages_processed, 2, |
| 731 |
'Processed 2 message with limit of 2 and 4 unprocessed messages' ); |
| 732 |
$messages_processed = C4::Letters::SendQueuedMessages( { limit => 3 } ); |
| 733 |
is( $messages_processed, 2, |
| 734 |
'Processed 2 message with limit of 3 and 2 unprocessed messages' ); |
| 735 |
}; |