Lines 924-930
subtest 'Test limit parameter for SendQueuedMessages' => sub {
Link Here
|
924 |
|
924 |
|
925 |
subtest 'Test message_id parameter for SendQueuedMessages' => sub { |
925 |
subtest 'Test message_id parameter for SendQueuedMessages' => sub { |
926 |
|
926 |
|
927 |
plan tests => 6; |
927 |
plan tests => 7; |
928 |
|
928 |
|
929 |
my $dbh = C4::Context->dbh; |
929 |
my $dbh = C4::Context->dbh; |
930 |
|
930 |
|
Lines 952-964
subtest 'Test message_id parameter for SendQueuedMessages' => sub {
Link Here
|
952 |
'from_address' => 'root@localhost.' # invalid KohaAdminEmailAddress |
952 |
'from_address' => 'root@localhost.' # invalid KohaAdminEmailAddress |
953 |
}; |
953 |
}; |
954 |
my $message_id = C4::Letters::EnqueueLetter($my_message); |
954 |
my $message_id = C4::Letters::EnqueueLetter($my_message); |
955 |
throws_ok { |
955 |
my $processed = C4::Letters::SendQueuedMessages( { message_id => $message_id } ); |
956 |
C4::Letters::SendQueuedMessages( { message_id => $message_id } ); |
956 |
is( $processed, 1, 'Processed 1 message when one message_id passed' ); |
957 |
} 'Koha::Exceptions::BadParameter', |
|
|
958 |
'Exception thrown if invalid email is passed'; |
959 |
my $message_1 = C4::Letters::GetMessage($message_id); |
957 |
my $message_1 = C4::Letters::GetMessage($message_id); |
960 |
# FIXME must be 'failed' |
958 |
is( $message_1->{status}, 'failed', 'Invalid KohaAdminEmailAddress => status failed' ); |
961 |
is( $message_1->{status}, 'pending', 'Invalid KohaAdminEmailAddress => status pending' ); |
959 |
is( $message_1->{failure_code}, 'INVALID_EMAIL', 'Failure code set correctly for invalid email parameter'); |
962 |
|
960 |
|
963 |
$my_message->{from_address} = 'root@example.org'; # valid KohaAdminEmailAddress |
961 |
$my_message->{from_address} = 'root@example.org'; # valid KohaAdminEmailAddress |
964 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
962 |
$message_id = C4::Letters::EnqueueLetter($my_message); |
Lines 967-972
subtest 'Test message_id parameter for SendQueuedMessages' => sub {
Link Here
|
967 |
"SendQueuedMessages is using the mocked send_or_die routine"; |
965 |
"SendQueuedMessages is using the mocked send_or_die routine"; |
968 |
$message_1 = C4::Letters::GetMessage($message_1->{message_id}); |
966 |
$message_1 = C4::Letters::GetMessage($message_1->{message_id}); |
969 |
my $message_2 = C4::Letters::GetMessage($message_id); |
967 |
my $message_2 = C4::Letters::GetMessage($message_id); |
970 |
is( $message_1->{status}, 'pending', 'Message 1 status is unchanged' ); # Must be 'failed' |
968 |
is( $message_1->{status}, 'failed', 'Message 1 status is unchanged' ); |
971 |
is( $message_2->{status}, 'sent', 'Valid KohaAdminEmailAddress => status sent' ); |
969 |
is( $message_2->{status}, 'sent', 'Valid KohaAdminEmailAddress => status sent' ); |
972 |
}; |
970 |
}; |
973 |
- |
|
|