Lines 18-26
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 => 83; |
21 |
use Test::More tests => 84; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
|
|
24 |
use Test::Exception; |
24 |
|
25 |
|
25 |
use Email::Sender::Failure; |
26 |
use Email::Sender::Failure; |
26 |
|
27 |
|
Lines 958-960
subtest 'Test limit parameter for SendQueuedMessages' => sub {
Link Here
|
958 |
is( $messages_processed, 2, |
959 |
is( $messages_processed, 2, |
959 |
'Processed 2 message with limit of 3 and 2 unprocessed messages' ); |
960 |
'Processed 2 message with limit of 3 and 2 unprocessed messages' ); |
960 |
}; |
961 |
}; |
961 |
- |
962 |
|
|
|
963 |
subtest 'Test message_id parameter for SendQueuedMessages' => sub { |
964 |
|
965 |
plan tests => 5; |
966 |
|
967 |
my $dbh = C4::Context->dbh; |
968 |
|
969 |
my $borrowernumber = Koha::Patron->new({ |
970 |
firstname => 'Jane', |
971 |
surname => 'Smith', |
972 |
categorycode => $patron_category, |
973 |
branchcode => $library->{branchcode}, |
974 |
dateofbirth => $date, |
975 |
smsalertnumber => undef, |
976 |
})->store->borrowernumber; |
977 |
|
978 |
$dbh->do(q|DELETE FROM message_queue|); |
979 |
$my_message = { |
980 |
'letter' => { |
981 |
'content' => 'a message', |
982 |
'metadata' => 'metadata', |
983 |
'code' => 'TEST_MESSAGE', |
984 |
'content_type' => 'text/plain', |
985 |
'title' => 'message title' |
986 |
}, |
987 |
'borrowernumber' => $borrowernumber, |
988 |
'to_address' => 'to@example.org', |
989 |
'message_transport_type' => 'email', |
990 |
'from_address' => 'root@localhost' # invalid KohaAdminEmailAddress |
991 |
}; |
992 |
my $message_id = C4::Letters::EnqueueLetter($my_message); |
993 |
throws_ok { |
994 |
C4::Letters::SendQueuedMessages( { message_id => $message_id } ); |
995 |
} 'Koha::Exceptions::BadParameter', |
996 |
'Exception thrown if invalid email is passed'; |
997 |
my $message_1 = C4::Letters::GetMessage($message_id); |
998 |
# FIXME must be 'failed' |
999 |
is( $message_1->{status}, 'pending', 'Invalid KohaAdminEmailAddress => status pending' ); |
1000 |
|
1001 |
$my_message->{from_address} = 'root@example.org'; # valid KohaAdminEmailAddress |
1002 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
1003 |
C4::Letters::SendQueuedMessages( { message_id => $message_id } ); |
1004 |
$message_1 = C4::Letters::GetMessage($message_1->{message_id}); |
1005 |
my $message_2 = C4::Letters::GetMessage($message_id); |
1006 |
is( $message_1->{status}, 'pending', 'Message 1 status is unchanged' ); # Must be 'failed' |
1007 |
is( $message_2->{status}, 'sent', 'Valid KohaAdminEmailAddress => status sent' ); |
1008 |
}; |