Bug 33210: Add unit test

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Nick <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Janusz Kaczmarek 2023-03-24 17:17:20 +01:00 committed by Tomas Cohen Arazi
parent dbd0117a49
commit 203646418a
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 18 additions and 1 deletions

View File

@ -52,6 +52,13 @@ $builder->build({
reservefee => 2,
},
});
$builder->build({
source => 'Category',
value => {
categorycode => 'XYZ2',
reservefee => 0,
},
});
my $patron1 = $builder->build({
source => 'Borrower',
value => {
@ -67,6 +74,12 @@ my $patron2 = $builder->build({
my $patron3 = $builder->build({
source => 'Borrower',
});
my $patron4 = $builder->build({
source => 'Borrower',
value => {
categorycode => 'XYZ2',
},
});
# One biblio and two items
my $biblio = $builder->build_sample_biblio;
@ -84,7 +97,7 @@ my $item2 = $builder->build_sample_item(
);
subtest 'GetReserveFee' => sub {
plan tests => 5;
plan tests => 6;
C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter
@ -109,6 +122,10 @@ subtest 'GetReserveFee' => sub {
t::lib::Mocks::mock_preference('HoldFeeMode', 'any_time_is_collected');
$fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->biblionumber );
is( int($fee), 2, 'HoldFeeMode=any_time_is_collected, Patron 2 should be charged' );
t::lib::Mocks::mock_preference('HoldFeeMode', 'any_time_is_placed');
$fee = C4::Reserves::GetReserveFee( $patron4->{borrowernumber}, $biblio->biblionumber );
is( $fee, 0, 'HoldFeeMode=any_time_is_placed ; fee == 0, Patron 4 should not be charged' );
};
subtest 'Integration with AddReserve' => sub {