From 5a437e289d1d1ec1d75984b17c4f0f520e15ce4d Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Fri, 20 May 2022 08:05:43 +0000 Subject: [PATCH] Bug 30788: Unit test Run: prove t/db_dependent/Circulation/CalcFine.t Signed-off-by: Martin Renvoize --- t/db_dependent/Circulation/CalcFine.t | 43 ++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation/CalcFine.t b/t/db_dependent/Circulation/CalcFine.t index d89c656e05..dc6b386d57 100755 --- a/t/db_dependent/Circulation/CalcFine.t +++ b/t/db_dependent/Circulation/CalcFine.t @@ -2,7 +2,8 @@ use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; +use Test::Warn; use C4::Context; use C4::Overdues qw( CalcFine ); @@ -100,6 +101,46 @@ subtest 'Test basic functionality' => sub { teardown(); }; +subtest 'Test with fine amount empty' => sub { + plan tests => 2; + + Koha::CirculationRules->set_rules( + { + branchcode => undef, + categorycode => undef, + itemtype => undef, + rules => { + fine => '', + lengthunit => 'days', + finedays => 0, + firstremind => 0, + chargeperiod => 1, + overduefinescap => undef, + cap_fine_to_replacement_price => 1, + }, + } + ); + + my $start_dt = DateTime->new( + year => 2000, + month => 1, + day => 1, + ); + + my $end_dt = DateTime->new( + year => 2000, + month => 1, + day => 30, + ); + + warning_is { + my ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); + } + undef, "No warning when fine amount is ''"; + + teardown(); +}; + subtest 'Test cap_fine_to_replacement_price' => sub { plan tests => 2; -- 2.20.1