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 84-90
$builder->build_sample_item(
Link Here
|
84 |
); |
84 |
); |
85 |
|
85 |
|
86 |
AddIssue( $patron, $barcode ); |
86 |
AddIssue( $patron, $barcode ); |
87 |
is( Koha::Patron::Discharge::can_be_discharged({ borrowernumber => $patron->borrowernumber }), 0, 'A patron with issues cannot be discharged' ); |
87 |
my ( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged({ borrowernumber => $patron->borrowernumber }); |
|
|
88 |
is( $can, 0, 'A patron with issues cannot be discharged' ); |
89 |
is( $problems->{checkouts}, 1, "Patron has checkouts" ); |
90 |
is( $problems->{debt}, undef, "Patron has no debt" ); |
88 |
|
91 |
|
89 |
is( Koha::Patron::Discharge::request({ borrowernumber => $patron->borrowernumber }), undef, 'No request done if patron has issues' ); |
92 |
is( Koha::Patron::Discharge::request({ borrowernumber => $patron->borrowernumber }), undef, 'No request done if patron has issues' ); |
90 |
is( Koha::Patron::Discharge::discharge({ borrowernumber => $patron->borrowernumber }), undef, 'No discharge done if patron has issues' ); |
93 |
is( Koha::Patron::Discharge::discharge({ borrowernumber => $patron->borrowernumber }), undef, 'No discharge done if patron has issues' ); |
Lines 100-113
$patron->account->add_debit(
Link Here
|
100 |
} |
103 |
} |
101 |
); |
104 |
); |
102 |
|
105 |
|
|
|
106 |
( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged({ borrowernumber => $patron->borrowernumber }); |
103 |
is( |
107 |
is( |
104 |
Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 0, |
108 |
$can, 0, |
105 |
'A patron with fines and checkouts cannot be discharged' |
109 |
'A patron with fines and checkouts cannot be discharged' |
106 |
); |
110 |
); |
|
|
111 |
is( $problems->{checkouts}, 1, "Patron has checkouts" ); |
112 |
is( $problems->{debt}, 0.1, "Patron has debt" ); |
107 |
|
113 |
|
108 |
AddReturn( $barcode ); |
114 |
AddReturn( $barcode ); |
109 |
|
115 |
|
110 |
is( Koha::Patron::Discharge::can_be_discharged({ borrowernumber => $patron->borrowernumber }), 0, 'A patron with fines cannot be discharged' ); |
116 |
( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged({ borrowernumber => $patron->borrowernumber }); |
|
|
117 |
is( |
118 |
$can, 0, |
119 |
'A patron with fines cannot be discharged' |
120 |
); |
121 |
is( $problems->{checkouts}, undef, "Patron has checkouts" ); |
122 |
is( $problems->{debt}, 0.1, "Patron has debt" ); |
111 |
|
123 |
|
112 |
|
124 |
|
113 |
$patron->account->pay( |
125 |
$patron->account->pay( |
Lines 117-126
$patron->account->pay(
Link Here
|
117 |
); |
129 |
); |
118 |
|
130 |
|
119 |
# Discharge possible without issue or fine |
131 |
# Discharge possible without issue or fine |
|
|
132 |
( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged({ borrowernumber => $patron->borrowernumber }); |
120 |
is( |
133 |
is( |
121 |
Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 1, |
134 |
$can, 1, |
122 |
'A patron without issues or fines can be discharged' |
135 |
'A patron without issues or fines can be discharged' |
123 |
); |
136 |
); |
|
|
137 |
is( scalar keys %$problems, 0, "No dishcharge problems found" ); |
124 |
|
138 |
|
125 |
is(Koha::Patron::Discharge::generate_as_pdf,undef,"Confirm failure when lacking borrower number"); |
139 |
is(Koha::Patron::Discharge::generate_as_pdf,undef,"Confirm failure when lacking borrower number"); |
126 |
|
140 |
|
127 |
- |
|
|