From 0860515897fbcedab332c093cc32193d37bed465 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 14 Jul 2023 07:32:11 -0400 Subject: [PATCH] Bug 34279: Unit tests Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 8096ec9fff44a04c8ff32525499652116d1a8ad0) Signed-off-by: Fridolin Somers (cherry picked from commit 3e360c5637c1f910100e10f049823fda01f588d9) Signed-off-by: Pedro Amorim --- t/db_dependent/Circulation/CalcFine.t | 80 ++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation/CalcFine.t b/t/db_dependent/Circulation/CalcFine.t index 23607b3160..628e45b460 100755 --- a/t/db_dependent/Circulation/CalcFine.t +++ b/t/db_dependent/Circulation/CalcFine.t @@ -2,7 +2,7 @@ use Modern::Perl; -use Test::More tests => 5; +use Test::More tests => 7; use Test::Warn; use C4::Context; @@ -101,6 +101,84 @@ subtest 'Test basic functionality' => sub { teardown(); }; +subtest 'Overdue fines cap should be disabled when value is 0' => sub { + plan tests => 1; + + Koha::CirculationRules->set_rules( + { + branchcode => undef, + categorycode => undef, + itemtype => undef, + rules => { + fine => '1.00', + lengthunit => 'days', + finedays => 0, + firstremind => 0, + chargeperiod => 1, + overduefinescap => "0", + cap_fine_to_replacement_price => 0, + } + }, + ); + + my $start_dt = DateTime->new( + year => 2000, + month => 1, + day => 1, + ); + + my $end_dt = DateTime->new( + year => 2000, + month => 1, + day => 30, + ); + + my ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); + + is( $amount, 29, 'Amount is calculated correctly' ); + + teardown(); +}; + +subtest 'Overdue fines cap should be disabled when value is 0.00' => sub { + plan tests => 1; + + Koha::CirculationRules->set_rules( + { + branchcode => undef, + categorycode => undef, + itemtype => undef, + rules => { + fine => '1.00', + lengthunit => 'days', + finedays => 0, + firstremind => 0, + chargeperiod => 1, + overduefinescap => "0.00", + cap_fine_to_replacement_price => 0, + } + }, + ); + + my $start_dt = DateTime->new( + year => 2000, + month => 1, + day => 1, + ); + + my $end_dt = DateTime->new( + year => 2000, + month => 1, + day => 30, + ); + + my ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); + + is( $amount, 29, 'Amount is calculated correctly' ); + + teardown(); +}; + subtest 'Test with fine amount empty' => sub { plan tests => 1; -- 2.20.1