Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 10; |
22 |
use Test::More tests => 11; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
25 |
use C4::Members; |
25 |
use C4::Members; |
Lines 251-256
subtest "delete" => sub {
Link Here
|
251 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
251 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
252 |
}; |
252 |
}; |
253 |
|
253 |
|
|
|
254 |
subtest 'add_enrolment_fee_if_needed' => sub { |
255 |
plan tests => 4; |
256 |
|
257 |
my $enrolmentfee_K = 5; |
258 |
my $enrolmentfee_J = 10; |
259 |
my $enrolmentfee_YA = 20; |
260 |
|
261 |
$builder->build( { source => 'Category', value => { categorycode => 'K', enrolmentfee => $enrolmentfee_K } } ); |
262 |
$builder->build( { source => 'Category', value => { categorycode => 'J', enrolmentfee => $enrolmentfee_J } } ); |
263 |
$builder->build( { source => 'Category', value => { categorycode => 'YA', enrolmentfee => $enrolmentfee_YA } } ); |
264 |
|
265 |
my %borrower_data = ( |
266 |
firstname => 'my firstname', |
267 |
surname => 'my surname', |
268 |
categorycode => 'K', |
269 |
branchcode => $library->{branchcode}, |
270 |
); |
271 |
|
272 |
my $borrowernumber = C4::Members::AddMember(%borrower_data); |
273 |
$borrower_data{borrowernumber} = $borrowernumber; |
274 |
|
275 |
my ($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
276 |
is( $total, $enrolmentfee_K, "New kid pay $enrolmentfee_K" ); |
277 |
|
278 |
t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 0 ); |
279 |
$borrower_data{categorycode} = 'J'; |
280 |
C4::Members::ModMember(%borrower_data); |
281 |
($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
282 |
is( $total, $enrolmentfee_K, "Kid growing and become a juvenile, but shouldn't pay for the upgrade " ); |
283 |
|
284 |
$borrower_data{categorycode} = 'K'; |
285 |
C4::Members::ModMember(%borrower_data); |
286 |
t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 1 ); |
287 |
|
288 |
$borrower_data{categorycode} = 'J'; |
289 |
C4::Members::ModMember(%borrower_data); |
290 |
($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
291 |
is( $total, $enrolmentfee_K + $enrolmentfee_J, "Kid growing and become a juvenile, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J ) ); |
292 |
|
293 |
# Check with calling directly Koha::Patron->get_enrolment_fee_if_needed |
294 |
my $patron = Koha::Patrons->find($borrowernumber); |
295 |
$patron->categorycode('YA')->store; |
296 |
my $fee = $patron->add_enrolment_fee_if_needed; |
297 |
($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
298 |
is( $total, |
299 |
$enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA, |
300 |
"Juvenile growing and become an young adult, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA ) |
301 |
); |
302 |
|
303 |
$patron->delete; |
304 |
}; |
305 |
|
254 |
$retrieved_patron_1->delete; |
306 |
$retrieved_patron_1->delete; |
255 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
307 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
256 |
|
308 |
|