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