From d3059e6c94f324d6984368fa8b8e77ad1dfbcf71 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 3 Apr 2019 15:59:20 +0100 Subject: [PATCH] Bug 20912: (QA follow-up) Fix for missed signature failure We missed a change in calling parameters passed to CalcDateDue in AddRenewal during the initial QAing. This patch corrects the call and adds a test to catch regressions. Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Dobrica Pavlinusic Signed-off-by: Nick Clemens --- C4/Circulation.pm | 2 +- t/db_dependent/Circulation.t | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index cf4077db11..a969b0ea17 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2842,7 +2842,7 @@ sub AddRenewal { $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? dt_from_string( $issue->date_due, 'sql' ) : DateTime->now( time_zone => C4::Context->tz()); - $datedue = CalcDateDue($datedue, $itemtype, $circ_library, $patron_unblessed, 'is a renewal'); + $datedue = CalcDateDue($datedue, $itemtype, $circ_library->branchcode, $patron_unblessed, 'is a renewal'); } my $fees = Koha::Charges::Fees->new( diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 9dac067f77..d2b6711ed4 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -18,11 +18,12 @@ use Modern::Perl; use utf8; -use Test::More tests => 125; +use Test::More tests => 126; use Test::MockModule; use Data::Dumper; use DateTime; +use Time::Fake; use POSIX qw( floor ); use t::lib::Mocks; use t::lib::TestBuilder; @@ -489,9 +490,13 @@ my ( $reused_itemnumber_1, $reused_itemnumber_2 ); action => "ISSUE" ); my $old_log_size = Koha::ActionLogs->count( \%params_renewal ); - AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch ); + my $dt = dt_from_string(); + Time::Fake->offset( $dt->epoch ); + my $datedue1 = AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch ); my $new_log_size = Koha::ActionLogs->count( \%params_renewal ); is ($new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog'); + isnt (DateTime->compare($datedue1, $dt), 0, "AddRenewal returned a good duedate"); + Time::Fake->reset; t::lib::Mocks::mock_preference('RenewalLog', 1); $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); -- 2.39.5