Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 46; |
20 |
use Test::More tests => 48; |
21 |
use DateTime::Duration; |
21 |
use DateTime::Duration; |
22 |
|
22 |
|
23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
Lines 297-316
subtest 'Show that AddRenewal respects OpacRenewalBranch and interface' => sub {
Link Here
|
297 |
} |
297 |
} |
298 |
}; |
298 |
}; |
299 |
|
299 |
|
300 |
# Unseen rewnewals |
|
|
301 |
t::lib::Mocks::mock_preference('UnseenRenewals', 1); |
302 |
|
303 |
# Does an unseen renewal increment the issue's count |
304 |
my ( $unseen_before ) = ( C4::Circulation::GetRenewCount( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber} ) )[3]; |
305 |
AddRenewal( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, $branchcode_1, undef, undef, 0 ); |
306 |
my ( $unseen_after ) = ( C4::Circulation::GetRenewCount( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber} ) )[3]; |
307 |
is( $unseen_after, $unseen_before + 1, 'unseen_renewals increments' ); |
308 |
|
309 |
# Does a seen renewal reset the unseen count |
310 |
AddRenewal( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, $branchcode_1, undef, undef, 1 ); |
311 |
my ( $unseen_reset ) = ( C4::Circulation::GetRenewCount( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber} ) )[3]; |
312 |
is( $unseen_reset, 0, 'seen renewal resets the unseen count' ); |
313 |
|
314 |
#Test GetBiblioIssues |
300 |
#Test GetBiblioIssues |
315 |
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" ); |
301 |
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" ); |
316 |
|
302 |
|
Lines 327-345
my $issue3 = C4::Circulation::AddIssue( $borrower_1, $barcode_1 );
Link Here
|
327 |
@renewcount = C4::Circulation::GetRenewCount(); |
313 |
@renewcount = C4::Circulation::GetRenewCount(); |
328 |
is_deeply( |
314 |
is_deeply( |
329 |
\@renewcount, |
315 |
\@renewcount, |
330 |
[ 0, 0, 0 ], # FIXME Need to be fixed, see FIXME in GetRenewCount |
316 |
[ 0, 0, 0, 0, 0, 0 ], # FIXME Need to be fixed, see FIXME in GetRenewCount |
331 |
"Without issuing rules and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0" |
317 |
"Without issuing rules and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0" |
332 |
); |
318 |
); |
333 |
@renewcount = C4::Circulation::GetRenewCount(-1); |
319 |
@renewcount = C4::Circulation::GetRenewCount(-1); |
334 |
is_deeply( |
320 |
is_deeply( |
335 |
\@renewcount, |
321 |
\@renewcount, |
336 |
[ 0, 0, 0 ], # FIXME Need to be fixed |
322 |
[ 0, 0, 0, 0, 0, 0 ], # FIXME Need to be fixed |
337 |
"Without issuing rules and without wrong parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0" |
323 |
"Without issuing rules and without wrong parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0" |
338 |
); |
324 |
); |
339 |
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); |
325 |
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); |
340 |
is_deeply( |
326 |
is_deeply( |
341 |
\@renewcount, |
327 |
\@renewcount, |
342 |
[ 2, 0, 0 ], |
328 |
[ 2, 0, 0, 0, 0, 0 ], |
343 |
"Without issuing rules and with a valid parameter, renewcount = 2, renewsallowed = undef, renewsleft = 0" |
329 |
"Without issuing rules and with a valid parameter, renewcount = 2, renewsallowed = undef, renewsleft = 0" |
344 |
); |
330 |
); |
345 |
|
331 |
|
Lines 347-365
is_deeply(
Link Here
|
347 |
@renewcount = C4::Circulation::GetRenewCount(); |
333 |
@renewcount = C4::Circulation::GetRenewCount(); |
348 |
is_deeply( |
334 |
is_deeply( |
349 |
\@renewcount, |
335 |
\@renewcount, |
350 |
[ 0, 0, 0 ], |
336 |
[ 0, 0, 0, 0, 0, 0 ], |
351 |
"With issuing rules (renewal disallowed) and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = 0, renewsleft = 0" |
337 |
"With issuing rules (renewal disallowed) and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = 0, renewsleft = 0" |
352 |
); |
338 |
); |
353 |
@renewcount = C4::Circulation::GetRenewCount(-1); |
339 |
@renewcount = C4::Circulation::GetRenewCount(-1); |
354 |
is_deeply( |
340 |
is_deeply( |
355 |
\@renewcount, |
341 |
\@renewcount, |
356 |
[ 0, 0, 0 ], |
342 |
[ 0, 0, 0, 0, 0, 0 ], |
357 |
"With issuing rules (renewal disallowed) and without wrong parameter, GetRenewCount returns renewcount = 0, renewsallowed = 0, renewsleft = 0" |
343 |
"With issuing rules (renewal disallowed) and without wrong parameter, GetRenewCount returns renewcount = 0, renewsallowed = 0, renewsleft = 0" |
358 |
); |
344 |
); |
359 |
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); |
345 |
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); |
360 |
is_deeply( |
346 |
is_deeply( |
361 |
\@renewcount, |
347 |
\@renewcount, |
362 |
[ 2, 0, 0 ], |
348 |
[ 2, 0, 0, 0, 0, 0 ], |
363 |
"With issuing rules (renewal disallowed) and with a valid parameter, Getrenewcount returns renewcount = 2, renewsallowed = 0, renewsleft = 0" |
349 |
"With issuing rules (renewal disallowed) and with a valid parameter, Getrenewcount returns renewcount = 2, renewsallowed = 0, renewsleft = 0" |
364 |
); |
350 |
); |
365 |
|
351 |
|
Lines 377-383
Koha::CirculationRules->set_rules(
Link Here
|
377 |
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); |
363 |
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); |
378 |
is_deeply( |
364 |
is_deeply( |
379 |
\@renewcount, |
365 |
\@renewcount, |
380 |
[ 2, 3, 1 ], |
366 |
[ 2, 3, 1, 0, 0, 0 ], |
381 |
"With issuing rules (renewal allowed) and with a valid parameter, Getrenewcount of item1 returns 3 renews left" |
367 |
"With issuing rules (renewal allowed) and with a valid parameter, Getrenewcount of item1 returns 3 renews left" |
382 |
); |
368 |
); |
383 |
|
369 |
|
Lines 386-392
AddRenewal( $borrower_id1, $item_id1, $branchcode_1,
Link Here
|
386 |
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); |
372 |
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); |
387 |
is_deeply( |
373 |
is_deeply( |
388 |
\@renewcount, |
374 |
\@renewcount, |
389 |
[ 3, 3, 0 ], |
375 |
[ 3, 3, 0, 0, 0, 0 ], |
390 |
"With issuing rules (renewal allowed, 1 remaining) and with a valid parameter, Getrenewcount of item1 returns 0 renews left" |
376 |
"With issuing rules (renewal allowed, 1 remaining) and with a valid parameter, Getrenewcount of item1 returns 0 renews left" |
391 |
); |
377 |
); |
392 |
|
378 |
|
Lines 504-508
AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' );
Link Here
|
504 |
my $hold = Koha::Holds->find( $reserve_id ); |
490 |
my $hold = Koha::Holds->find( $reserve_id ); |
505 |
is( $hold, undef, 'The reserve should have been correctly cancelled' ); |
491 |
is( $hold, undef, 'The reserve should have been correctly cancelled' ); |
506 |
|
492 |
|
|
|
493 |
# Unseen rewnewals |
494 |
t::lib::Mocks::mock_preference('UnseenRenewals', 1); |
495 |
# Add a default circ rule: 3 unseen renewals allowed |
496 |
Koha::CirculationRules->set_rules( |
497 |
{ |
498 |
categorycode => undef, |
499 |
itemtype => undef, |
500 |
branchcode => undef, |
501 |
rules => { |
502 |
renewalsallowed => 10, |
503 |
unseen_renewals_allowed => 3 |
504 |
} |
505 |
} |
506 |
); |
507 |
|
508 |
my $unseen_library = $builder->build_object( { class => 'Koha::Libraries' } ); |
509 |
my $unseen_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
510 |
my $unseen_item = $builder->build_sample_item( |
511 |
{ library => $unseen_library->branchcode, itype => $itemtype } ); |
512 |
my $unseen_issue = C4::Circulation::AddIssue( $unseen_patron->unblessed, $unseen_item->barcode ); |
513 |
|
514 |
# Does an unseen renewal increment the issue's count |
515 |
my ( $unseen_before ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3]; |
516 |
AddRenewal( $unseen_patron->borrowernumber, $unseen_item->itemnumber, $branchcode_1, undef, undef, undef, 0 ); |
517 |
my ( $unseen_after ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3]; |
518 |
is( $unseen_after, $unseen_before + 1, 'unseen_renewals increments' ); |
519 |
|
520 |
# Does a seen renewal reset the unseen count |
521 |
AddRenewal( $unseen_patron->borrowernumber, $unseen_item->itemnumber, $branchcode_1, undef, undef, undef, 1 ); |
522 |
my ( $unseen_reset ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3]; |
523 |
is( $unseen_reset, 0, 'seen renewal resets the unseen count' ); |
524 |
|
507 |
#End transaction |
525 |
#End transaction |
508 |
$schema->storage->txn_rollback; |
526 |
$schema->storage->txn_rollback; |
509 |
- |
|
|