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

(-)a/C4/Letters.pm (-3 / +8 lines)
Lines 25-42 use Module::Load::Conditional qw( can_load ); Link Here
25
25
26
use Try::Tiny;
26
use Try::Tiny;
27
27
28
use C4::Members;
29
use C4::Log qw( logaction );
28
use C4::Log qw( logaction );
29
use C4::Members;
30
use C4::SMS;
30
use C4::SMS;
31
use C4::Templates;
31
use C4::Templates;
32
use Koha::SMS::Providers;
32
use Koha::Auth::TwoFactorAuth;
33
33
use Koha::DateUtils qw( dt_from_string output_pref );
34
use Koha::Email;
34
use Koha::Email;
35
use Koha::Exceptions;
35
use Koha::Notice::Messages;
36
use Koha::Notice::Messages;
36
use Koha::Notice::Templates;
37
use Koha::Notice::Templates;
37
use Koha::DateUtils qw( dt_from_string output_pref );
38
use Koha::DateUtils qw( dt_from_string output_pref );
38
use Koha::Auth::TwoFactorAuth;
39
use Koha::Auth::TwoFactorAuth;
39
use Koha::Patrons;
40
use Koha::Patrons;
41
use Koha::SMS::Providers;
40
use Koha::SMTP::Servers;
42
use Koha::SMTP::Servers;
41
use Koha::Subscriptions;
43
use Koha::Subscriptions;
42
44
Lines 973-978 Returns number of messages sent. Link Here
973
sub SendQueuedMessages {
975
sub SendQueuedMessages {
974
    my $params = shift;
976
    my $params = shift;
975
977
978
    Koha::Exceptions::BadParameter->throw("Parameter message_id cannot be empty if passed.")
979
        if ( exists( $params->{message_id} ) && !$params->{message_id} );
980
976
    my $which_unsent_messages  = {
981
    my $which_unsent_messages  = {
977
        'message_id'     => $params->{'message_id'},
982
        'message_id'     => $params->{'message_id'},
978
        'limit'          => $params->{'limit'} // 0,
983
        'limit'          => $params->{'limit'} // 0,
(-)a/t/db_dependent/Letters.t (-2 / +17 lines)
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 => 89;
21
use Test::More tests => 92;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
use Test::Exception;
24
use Test::Exception;
Lines 153-158 my $yesterday = dt_from_string->subtract( days => 1 ); Link Here
153
Koha::Notice::Messages->find($messages->[0]->{message_id})->time_queued($yesterday)->store;
153
Koha::Notice::Messages->find($messages->[0]->{message_id})->time_queued($yesterday)->store;
154
154
155
# SendQueuedMessages
155
# SendQueuedMessages
156
157
throws_ok {
158
    C4::Letters::SendQueuedMessages( { message_id => undef } );
159
}
160
'Koha::Exceptions::BadParameter', 'Undef message_id throws an exception';
161
162
throws_ok {
163
    C4::Letters::SendQueuedMessages( { message_id => 0 } );
164
}
165
'Koha::Exceptions::BadParameter', 'message_id of 0 throws an exception';
166
167
throws_ok {
168
    C4::Letters::SendQueuedMessages( { message_id => q{} } );
169
}
170
'Koha::Exceptions::BadParameter', 'Empty string message_id throws an exception';
171
156
my $messages_processed = C4::Letters::SendQueuedMessages( { type => 'email' });
172
my $messages_processed = C4::Letters::SendQueuedMessages( { type => 'email' });
157
is($messages_processed, 0, 'No queued messages processed if type limit passed with unused type');
173
is($messages_processed, 0, 'No queued messages processed if type limit passed with unused type');
158
$messages_processed = C4::Letters::SendQueuedMessages( { type => 'sms' });
174
$messages_processed = C4::Letters::SendQueuedMessages( { type => 'sms' });
159
- 

Return to bug 34731