View | Details | Raw Unified | Return to bug 8000
Collapse All | Expand All

(-)a/t/db_dependent/Letters.t (-5 / +21 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 4;
22
use Test::More tests => 5;
23
23
24
use C4::Context;
24
use C4::Context;
25
use C4::Letters;
25
use C4::Letters;
Lines 40-45 my $borrowernumber = AddMember( Link Here
40
    branchcode   => 'CPL',
40
    branchcode   => 'CPL',
41
);
41
);
42
42
43
# used to trigger _send_message_by_sms in C4::Letter
43
my $message_id = C4::Letters::EnqueueLetter({
44
my $message_id = C4::Letters::EnqueueLetter({
44
    borrowernumber         => $borrowernumber,
45
    borrowernumber         => $borrowernumber,
45
    message_transport_type => 'sms',
46
    message_transport_type => 'sms',
Lines 54-66 my $message_id = C4::Letters::EnqueueLetter({ Link Here
54
    },
55
    },
55
});
56
});
56
57
57
ok(defined $message_id && $message_id > 0, 'new message successfully queued');
58
# used to trigger _send_message_by_email in C4::Letter
59
my $message_id2 = C4::Letters::EnqueueLetter({
60
    borrowernumber         => $borrowernumber,
61
    message_transport_type => 'email',
62
    to_address             => 'to@example.com',
63
    from_address           => 'from@example.com',
64
    letter => {
65
        content      => 'a message',
66
        title        => 'message title',
67
        metadata     => 'metadata',
68
        code         => 'TEST_MESSAGE',
69
        content_type => 'text/plain',
70
    },
71
});
72
73
ok(defined $message_id  && $message_id  > 0, 'new message successfully queued');
74
ok(defined $message_id2 && $message_id2 > 0, 'new message successfully queued');
58
75
59
my $messages_processed = C4::Letters::SendQueuedMessages();
76
my $messages_processed = C4::Letters::SendQueuedMessages();
60
is($messages_processed, 1, 'all queued messages processed');
77
is($messages_processed, 2, 'all queued messages processed');
61
78
62
my $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
79
my $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
63
is(scalar(@$messages), 1, 'one message stored for the borrower');
80
is(scalar(@$messages), 2, 'two messages stored for the borrower');
64
81
65
is(
82
is(
66
    $messages->[0]->{status},
83
    $messages->[0]->{status},
67
- 

Return to bug 8000