Lines 16-22
Link Here
|
16 |
|
16 |
|
17 |
use Modern::Perl; |
17 |
use Modern::Perl; |
18 |
|
18 |
|
19 |
use Test::More tests => 25; |
19 |
use Test::More tests => 32; |
20 |
|
20 |
|
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
Lines 89-98
$builder->build_sample_item(
Link Here
|
89 |
); |
89 |
); |
90 |
|
90 |
|
91 |
AddIssue( $patron, $barcode ); |
91 |
AddIssue( $patron, $barcode ); |
92 |
is( |
92 |
my ( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ); |
93 |
Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 0, |
93 |
is( $can, 0, 'A patron with issues cannot be discharged' ); |
94 |
'A patron with issues cannot be discharged' |
94 |
is( $problems->{checkouts}, 1, "Patron has checkouts" ); |
95 |
); |
95 |
is( $problems->{debt}, undef, "Patron has no debt" ); |
96 |
|
96 |
|
97 |
is( |
97 |
is( |
98 |
Koha::Patron::Discharge::request( { borrowernumber => $patron->borrowernumber } ), undef, |
98 |
Koha::Patron::Discharge::request( { borrowernumber => $patron->borrowernumber } ), undef, |
Lines 114-130
$patron->account->add_debit(
Link Here
|
114 |
} |
114 |
} |
115 |
); |
115 |
); |
116 |
|
116 |
|
|
|
117 |
( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ); |
117 |
is( |
118 |
is( |
118 |
Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 0, |
119 |
$can, 0, |
119 |
'A patron with fines and checkouts cannot be discharged' |
120 |
'A patron with fines and checkouts cannot be discharged' |
120 |
); |
121 |
); |
|
|
122 |
is( $problems->{checkouts}, 1, "Patron has checkouts" ); |
123 |
is( $problems->{debt}, 0.1, "Patron has debt" ); |
121 |
|
124 |
|
122 |
AddReturn($barcode); |
125 |
AddReturn($barcode); |
123 |
|
126 |
|
|
|
127 |
( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ); |
124 |
is( |
128 |
is( |
125 |
Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 0, |
129 |
$can, 0, |
126 |
'A patron with fines cannot be discharged' |
130 |
'A patron with fines cannot be discharged' |
127 |
); |
131 |
); |
|
|
132 |
is( $problems->{checkouts}, undef, "Patron has checkouts" ); |
133 |
is( $problems->{debt}, 0.1, "Patron has debt" ); |
128 |
|
134 |
|
129 |
$patron->account->pay( |
135 |
$patron->account->pay( |
130 |
{ |
136 |
{ |
Lines 133-142
$patron->account->pay(
Link Here
|
133 |
); |
139 |
); |
134 |
|
140 |
|
135 |
# Discharge possible without issue or fine |
141 |
# Discharge possible without issue or fine |
|
|
142 |
( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ); |
136 |
is( |
143 |
is( |
137 |
Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 1, |
144 |
$can, 1, |
138 |
'A patron without issues or fines can be discharged' |
145 |
'A patron without issues or fines can be discharged' |
139 |
); |
146 |
); |
|
|
147 |
is( scalar keys %$problems, 0, "No dishcharge problems found" ); |
140 |
|
148 |
|
141 |
is( Koha::Patron::Discharge::generate_as_pdf, undef, "Confirm failure when lacking borrower number" ); |
149 |
is( Koha::Patron::Discharge::generate_as_pdf, undef, "Confirm failure when lacking borrower number" ); |
142 |
|
150 |
|
143 |
- |
|
|