3 # This file is part of Koha.
5 # Copyright (C) 2013 Equinox Software, Inc.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Test::More tests => 4;
28 my $dbh = C4::Context->dbh;
31 $dbh->{AutoCommit} = 0;
32 $dbh->{RaiseError} = 1;
34 $dbh->do('DELETE FROM message_queue');
36 my $borrowernumber = AddMember(
43 my $message_id = C4::Letters::EnqueueLetter({
44 borrowernumber => $borrowernumber,
45 message_transport_type => 'sms',
46 to_address => 'to@example.com',
47 from_address => 'from@example.com',
49 content => 'a message',
50 title => 'message title',
51 metadata => 'metadata',
52 code => 'TEST_MESSAGE',
53 content_type => 'text/plain',
57 ok(defined $message_id && $message_id > 0, 'new message successfully queued');
59 my $messages_processed = C4::Letters::SendQueuedMessages();
60 is($messages_processed, 1, 'all queued messages processed');
62 my $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
63 is(scalar(@$messages), 1, 'one message stored for the borrower');
66 $messages->[0]->{status},
68 'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'