From d1213134a6c998872990c014f045bb0b82eb1fd6 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 16 Jul 2020 16:46:22 +0000 Subject: [PATCH] Bug 15986: Rename send_notice to queue_notice and update test count Signed-off-by: Kim Gnerre Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- Koha/Patron.pm | 10 +++++----- misc/cronjobs/holds_reminder.pl | 4 ++-- t/db_dependent/Koha/Patrons.t | 22 +++++++++++----------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 06c4a34b37..7f30fa7e82 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1810,11 +1810,11 @@ sub to_api_mapping { }; } -=head3 send_notice +=head3 queue_notice - Koha::Patrons->send_notice({ letter_params => $letter_params, message_name => 'DUE'}); - Koha::Patrons->send_notice({ letter_params => $letter_params, message_transports => \@message_transports }); - Koha::Patrons->send_notice({ letter_params => $letter_params, message_transports => \@message_transports, test_mode => 1 }); + Koha::Patrons->queue_notice({ letter_params => $letter_params, message_name => 'DUE'}); + Koha::Patrons->queue_notice({ letter_params => $letter_params, message_transports => \@message_transports }); + Koha::Patrons->queue_notice({ letter_params => $letter_params, message_transports => \@message_transports, test_mode => 1 }); Queue messages to a patron. Can pass a message that is part of the message_attributes table or supply the transport to use. @@ -1829,7 +1829,7 @@ sub to_api_mapping { =cut -sub send_notice { +sub queue_notice { my ( $self, $params ) = @_; my $letter_params = $params->{letter_params}; my $test_mode = $params->{test_mode}; diff --git a/misc/cronjobs/holds_reminder.pl b/misc/cronjobs/holds_reminder.pl index d892ccfa49..0a88fa7d5e 100755 --- a/misc/cronjobs/holds_reminder.pl +++ b/misc/cronjobs/holds_reminder.pl @@ -282,8 +282,8 @@ foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP $sending_params->{letter_params} = $letter_params; $sending_params->{test_mode} = $nomail; my $result_text = $nomail ? "would have been sent" : "was sent"; - # send_notice queues the notices, falling back to print for email or SMS, and ignores phone (they are handled by Itiva) - my $result = $patron->send_notice( $sending_params ); + # queue_notice queues the notices, falling back to print for email or SMS, and ignores phone (they are handled by Itiva) + my $result = $patron->queue_notice( $sending_params ); $verbose and print " borrower " . $patron->surname . ", " . $patron->firstname . " $result_text notices via: @{$result->{sent}}\n" if defined $result->{sent}; $verbose and print " borrower " . $patron->surname . ", " . $patron->firstname . " $result_text print fallback for: @{$result->{fallback}}\n" if defined $result->{fallback}; # Mark this borrower as completed diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 0b310dd90e..5d54d56fbe 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 41; +use Test::More tests => 42; use Test::Warn; use Test::Exception; use Test::MockModule; @@ -1981,7 +1981,7 @@ subtest 'anonymize' => sub { is( $patron2->firstname, undef, 'First name patron2 cleared' ); }; -subtest 'send_notice' => sub { +subtest 'queue_notice' => sub { plan tests => 11; my $dbh = C4::Context->dbh; @@ -2028,26 +2028,26 @@ subtest 'send_notice' => sub { }; my @mtts = ('email'); - is( $patron->send_notice(), undef, "Nothing is done if no params passed"); - is( $patron->send_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); + is( $patron->queue_notice(), undef, "Nothing is done if no params passed"); + is( $patron->queue_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); is_deeply( - $patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), + $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), {sent => ['email'] }, "Email sent" ); $patron->email("")->store; is_deeply( - $patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), + $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), {sent => ['print'],fallback => ['email']}, "Email fallsback to print if no email" ); push @mtts, 'sms'; is_deeply( - $patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), + $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), {sent => ['print','sms'],fallback => ['email']}, "Email fallsback to print if no email, sms sent" ); $patron->smsalertnumber("")->store; my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; is_deeply( - $patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), + $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), {sent => ['print'],fallback => ['email','sms']}, "Email fallsback to print if no emai, sms fallsback to print if no sms, only one print sent" ); is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); @@ -2057,16 +2057,16 @@ subtest 'send_notice' => sub { my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); $dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); - is( $patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); + is( $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); $patron->email(q|awesome@ismymiddle.name|)->store; is_deeply( - $patron->send_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), + $patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), {sent => ['email'] }, "Email sent when using borrower preferences" ); $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; is_deeply( - $patron->send_notice({ letter_params => $letter_params, message_name => 'Hold_Filled', test_mode => 1 }), + $patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled', test_mode => 1 }), {sent => ['email'] }, "Report that email sent when using borrower preferences in test_mode" ); is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter,"Count of queued notices not increased in test mode"); -- 2.39.5