Bug 18344: Add unit tests

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Kyle M Hall 2019-03-25 13:55:43 -04:00 committed by Martin Renvoize
parent e702ff89f7
commit 60e24be115
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 45 additions and 1 deletions

View File

@ -2,7 +2,7 @@
use Modern::Perl;
use Test::More tests => 2;
use Test::More tests => 3;
use C4::Context;
use C4::Overdues;
@ -169,6 +169,50 @@ subtest 'Test cap_fine_to_replacement_price' => sub {
teardown();
};
subtest 'Test cap_fine_to_replacement_pricew with overduefinescap' => sub {
plan tests => 2;
t::lib::Mocks::mock_preference('useDefaultReplacementCost', '1');
my $issuingrule = $builder->build_object(
{
class => 'Koha::IssuingRules',
value => {
branchcode => '*',
categorycode => '*',
itemtype => '*',
fine => '1.00',
lengthunit => 'days',
finedays => 0,
firstremind => 0,
chargeperiod => 1,
overduefinescap => 3,
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,
);
my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
is( int($amount), 3, 'Got the lesser of overduefinescap and replacement price where overduefinescap < replacement price' );
$issuingrule->overduefinescap(6)->store();
($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt );
is( int($amount), 5, 'Get the lesser of overduefinescap and replacement price where overduefinescap > replacement price' );
teardown();
};
sub teardown {
$dbh->do(q|DELETE FROM issuingrules|);
}