|
Lines 21-29
Link Here
|
| 21 |
|
21 |
|
| 22 |
use Modern::Perl; |
22 |
use Modern::Perl; |
| 23 |
|
23 |
|
| 24 |
use Test::More tests => 5; |
24 |
use Test::More tests => 6; |
| 25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
| 26 |
use t::lib::TestBuilder; |
26 |
use t::lib::TestBuilder; |
|
|
27 |
use t::lib::Mocks; |
| 27 |
|
28 |
|
| 28 |
use C4::Circulation; |
29 |
use C4::Circulation; |
| 29 |
use C4::Reserves qw|AddReserve|; |
30 |
use C4::Reserves qw|AddReserve|; |
|
Lines 48-54
$builder->build({
Link Here
|
| 48 |
source => 'Category', |
49 |
source => 'Category', |
| 49 |
value => { |
50 |
value => { |
| 50 |
categorycode => 'XYZ1', |
51 |
categorycode => 'XYZ1', |
| 51 |
reservefee => 2.5, |
52 |
reservefee => 2, |
| 52 |
}, |
53 |
}, |
| 53 |
}); |
54 |
}); |
| 54 |
my $patron1 = $builder->build({ |
55 |
my $patron1 = $builder->build({ |
|
Lines 96-101
is( acctlines( $patron1->{borrowernumber} ), $acc1, 'No fee charged for patron 1
Link Here
|
| 96 |
# expect a charge for patron2. |
97 |
# expect a charge for patron2. |
| 97 |
C4::Circulation::AddIssue( $patron1, $item1->{barcode}, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter |
98 |
C4::Circulation::AddIssue( $patron1, $item1->{barcode}, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter |
| 98 |
my $acc2 = acctlines( $patron2->{borrowernumber} ); |
99 |
my $acc2 = acctlines( $patron2->{borrowernumber} ); |
|
|
100 |
t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always'); |
| 99 |
my $fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); |
101 |
my $fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); |
| 100 |
is( $fee > 0, 1, 'Patron 2 should be charged cf GetReserveFee' ); |
102 |
is( $fee > 0, 1, 'Patron 2 should be charged cf GetReserveFee' ); |
| 101 |
C4::Reserves::ChargeReserveFee( $patron2->{borrowernumber}, $fee, $biblio->{title} ); |
103 |
C4::Reserves::ChargeReserveFee( $patron2->{borrowernumber}, $fee, $biblio->{title} ); |
|
Lines 104-115
is( acctlines( $patron2->{borrowernumber} ), $acc2 + 1, 'Patron 2 has been charg
Link Here
|
| 104 |
# If we delete the reserve, there should be no charge |
106 |
# If we delete the reserve, there should be no charge |
| 105 |
$dbh->do( "DELETE FROM reserves WHERE reserve_id=?", undef, ( $res1 ) ); |
107 |
$dbh->do( "DELETE FROM reserves WHERE reserve_id=?", undef, ( $res1 ) ); |
| 106 |
$fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); |
108 |
$fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); |
| 107 |
is( $fee, 0, 'Patron 2 will not be charged now' ); |
109 |
is( $fee, 0, 'HoldFeeMode=not_always, Patron 2 should not be charged' ); |
|
|
110 |
|
| 111 |
t::lib::Mocks::mock_preference('HoldFeeMode', 'always'); |
| 112 |
$fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); |
| 113 |
is( int($fee), 2, 'HoldFeeMode=always, Patron 2 should be charged' ); |
| 108 |
|
114 |
|
| 109 |
# If we delete the second item, there should be a charge |
115 |
# If we delete the second item, there should be a charge |
| 110 |
$dbh->do( "DELETE FROM items WHERE itemnumber=?", undef, ( $item2->{itemnumber} ) ); |
116 |
$dbh->do( "DELETE FROM items WHERE itemnumber=?", undef, ( $item2->{itemnumber} ) ); |
| 111 |
$fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); |
117 |
$fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); |
| 112 |
is( $fee > 0, 1, 'Patron 2 should be charged again this time' ); |
118 |
is( int($fee), 2, 'Patron 2 should be charged again this time' ); |
| 113 |
# End of tests |
119 |
# End of tests |
| 114 |
|
120 |
|
| 115 |
sub acctlines { #calculate number of accountlines for a patron |
121 |
sub acctlines { #calculate number of accountlines for a patron |
| 116 |
- |
|
|