Bug 30788: Unit test

Run:
  prove t/db_dependent/Circulation/CalcFine.t

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit e59e2c4b8f)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Katrin Fischer 2022-05-20 08:05:43 +00:00 committed by Lucas Gass
parent 4b3fe8ff3c
commit ee33b31c55
1 changed files with 42 additions and 1 deletions

View File

@ -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 => 1;
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;