From 9b4d4427384845340d4e83765aeb6160e1f092b4 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 14 Jul 2022 10:38:57 +0000 Subject: [PATCH] Bug 31120: Add unit tests Signed-off-by: Martin Renvoize --- t/db_dependent/Circulation/CalcDateDue.t | 39 +++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation/CalcDateDue.t b/t/db_dependent/Circulation/CalcDateDue.t index af23654b2b..cdcd800870 100755 --- a/t/db_dependent/Circulation/CalcDateDue.t +++ b/t/db_dependent/Circulation/CalcDateDue.t @@ -2,7 +2,7 @@ use Modern::Perl; -use Test::More tests => 17; +use Test::More tests => 19; use Test::MockModule; use DBI; use DateTime; @@ -303,5 +303,42 @@ $calendar->delete_holiday( weekday => 6 ); +# Renewal period of 0 is valid +Koha::CirculationRules->search()->delete(); +Koha::CirculationRules->set_rules( + { + categorycode => undef, + itemtype => undef, + branchcode => undef, + rules => { + issuelength => 9999, + renewalperiod => 0, + lengthunit => 'days', + daysmode => 'Days', + } + } +); +$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); +is( $date->ymd, $start_date->ymd, "Dates should match for renewalperiod of 0" ); + +# Renewal period of "" should trigger fallover to issuelength for renewal +Koha::CirculationRules->search()->delete(); +Koha::CirculationRules->set_rules( + { + categorycode => undef, + itemtype => undef, + branchcode => undef, + rules => { + issuelength => 7, + renewalperiod => q{}, + lengthunit => 'days', + daysmode => 'Days', + } + } +); +my $renewed_date = $start_date->clone->add( days => 7 ); +$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); +is( $date->ymd, $renewed_date->ymd, 'Renewal period of "" should trigger fallover to issuelength for renewal' ); + $cache->clear_from_cache($key); $schema->storage->txn_rollback; -- 2.20.1