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 => 61; |
21 |
use Test::More tests => 63; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
Lines 86-91
is_deeply( $mtts, ['email', 'phone', 'print', 'sms'], 'GetMessageTransportTypes
Link Here
|
86 |
# EnqueueLetter |
86 |
# EnqueueLetter |
87 |
is( C4::Letters::EnqueueLetter(), undef, 'EnqueueLetter without argument returns undef' ); |
87 |
is( C4::Letters::EnqueueLetter(), undef, 'EnqueueLetter without argument returns undef' ); |
88 |
|
88 |
|
|
|
89 |
# used to trigger _send_message_by_sms in C4::Letter |
89 |
my $my_message = { |
90 |
my $my_message = { |
90 |
borrowernumber => $borrowernumber, |
91 |
borrowernumber => $borrowernumber, |
91 |
message_transport_type => 'sms', |
92 |
message_transport_type => 'sms', |
Lines 110-122
$my_message->{message_transport_type} = 'sms';
Link Here
|
110 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
111 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
111 |
ok(defined $message_id && $message_id > 0, 'new message successfully queued'); |
112 |
ok(defined $message_id && $message_id > 0, 'new message successfully queued'); |
112 |
|
113 |
|
|
|
114 |
# used to trigger _send_message_by_email in C4::Letter |
115 |
my $message_id2 = C4::Letters::EnqueueLetter({ |
116 |
borrowernumber => $borrowernumber, |
117 |
message_transport_type => 'email', |
118 |
to_address => 'to@example.com', |
119 |
from_address => 'from@example.com', |
120 |
letter => { |
121 |
content => 'a message', |
122 |
title => 'message title', |
123 |
metadata => 'metadata', |
124 |
code => 'TEST_MESSAGE', |
125 |
content_type => 'text/plain', |
126 |
}, |
127 |
}); |
128 |
|
129 |
ok(defined $message_id2 && $message_id2 > 0, 'new message successfully queued'); |
130 |
|
113 |
|
131 |
|
114 |
# GetQueuedMessages |
132 |
# GetQueuedMessages |
115 |
my $messages = C4::Letters::GetQueuedMessages(); |
133 |
my $messages = C4::Letters::GetQueuedMessages(); |
116 |
is( @$messages, 1, 'GetQueuedMessages without argument returns all the entries' ); |
134 |
is( @$messages, 2, 'GetQueuedMessages without argument returns all the entries' ); |
117 |
|
135 |
|
118 |
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); |
136 |
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); |
119 |
is( @$messages, 1, 'one message stored for the borrower' ); |
137 |
is( @$messages, 2, 'two messages stored for the borrower' ); |
120 |
is( $messages->[0]->{message_id}, $message_id, 'EnqueueLetter returns the message id correctly' ); |
138 |
is( $messages->[0]->{message_id}, $message_id, 'EnqueueLetter returns the message id correctly' ); |
121 |
is( $messages->[0]->{borrowernumber}, $borrowernumber, 'EnqueueLetter stores the borrower number correctly' ); |
139 |
is( $messages->[0]->{borrowernumber}, $borrowernumber, 'EnqueueLetter stores the borrower number correctly' ); |
122 |
is( $messages->[0]->{subject}, $my_message->{letter}->{title}, 'EnqueueLetter stores the subject correctly' ); |
140 |
is( $messages->[0]->{subject}, $my_message->{letter}->{title}, 'EnqueueLetter stores the subject correctly' ); |
Lines 127-135
is( $messages->[0]->{status}, 'pending', 'EnqueueLetter stores the status pendin
Link Here
|
127 |
|
145 |
|
128 |
# SendQueuedMessages |
146 |
# SendQueuedMessages |
129 |
my $messages_processed = C4::Letters::SendQueuedMessages(); |
147 |
my $messages_processed = C4::Letters::SendQueuedMessages(); |
130 |
is($messages_processed, 1, 'all queued messages processed'); |
148 |
is($messages_processed, 2, 'all queued messages processed'); |
131 |
|
149 |
|
132 |
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); |
150 |
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); |
|
|
151 |
is(scalar(@$messages), 2, 'two messages stored for the borrower'); |
152 |
|
133 |
is( |
153 |
is( |
134 |
$messages->[0]->{status}, |
154 |
$messages->[0]->{status}, |
135 |
'failed', |
155 |
'failed', |
136 |
- |
|
|