Bug 20912: (QA follow-up) Fix for missed signature failure
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 3 Apr 2019 14:59:20 +0000 (15:59 +0100)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 11 Apr 2019 11:30:04 +0000 (11:30 +0000)
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 <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Dobrica Pavlinusic <dpavlin@rot13.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/Circulation.pm
t/db_dependent/Circulation.t

index cf4077d..a969b0e 100644 (file)
@@ -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(
index 9dac067..d2b6711 100755 (executable)
 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' } );