From 3369a2cde0b49c90dc59bbd41c3a77d392526283 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Fri, 24 Mar 2023 17:17:20 +0100 Subject: [PATCH] Bug 33210: Add unit test Signed-off-by: David Nind --- t/db_dependent/Reserves/GetReserveFee.t | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Reserves/GetReserveFee.t b/t/db_dependent/Reserves/GetReserveFee.t index 958e6c3527..ce00290c0b 100755 --- a/t/db_dependent/Reserves/GetReserveFee.t +++ b/t/db_dependent/Reserves/GetReserveFee.t @@ -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 { -- 2.30.2