|
Lines 85-97
t::lib::Mocks::mock_userenv({ branchcode => $branch_1 });
Link Here
|
| 85 |
my $bibnum = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber; |
85 |
my $bibnum = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber; |
| 86 |
|
86 |
|
| 87 |
# Create a helper item instance for testing |
87 |
# Create a helper item instance for testing |
| 88 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
88 |
my $itemnumber = $builder->build_sample_item({ biblionumber => $bibnum, library => $branch_1, itype => $itemtype })->itemnumber; |
| 89 |
{ homebranch => $branch_1, |
|
|
| 90 |
holdingbranch => $branch_1, |
| 91 |
itype => $itemtype |
| 92 |
}, |
| 93 |
$bibnum |
| 94 |
); |
| 95 |
|
89 |
|
| 96 |
my $biblio_with_no_item = $builder->build({ |
90 |
my $biblio_with_no_item = $builder->build({ |
| 97 |
source => 'Biblio' |
91 |
source => 'Biblio' |
|
Lines 127-139
AddReserve(
Link Here
|
| 127 |
} |
121 |
} |
| 128 |
); |
122 |
); |
| 129 |
|
123 |
|
| 130 |
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); |
124 |
my ($status, $reserve, $all_reserves) = CheckReserves($item->itemnumber, $barcode); |
| 131 |
|
125 |
|
| 132 |
is($status, "Reserved", "CheckReserves Test 1"); |
126 |
is($status, "Reserved", "CheckReserves Test 1"); |
| 133 |
|
127 |
|
| 134 |
ok(exists($reserve->{reserve_id}), 'CheckReserves() include reserve_id in its response'); |
128 |
ok(exists($reserve->{reserve_id}), 'CheckReserves() include reserve_id in its response'); |
| 135 |
|
129 |
|
| 136 |
($status, $reserve, $all_reserves) = CheckReserves($itemnumber); |
130 |
($status, $reserve, $all_reserves) = CheckReserves($item->itemnumber); |
| 137 |
is($status, "Reserved", "CheckReserves Test 2"); |
131 |
is($status, "Reserved", "CheckReserves Test 2"); |
| 138 |
|
132 |
|
| 139 |
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode); |
133 |
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode); |
|
Lines 227-249
Koha::CirculationRules->set_rules(
Link Here
|
| 227 |
my $bibnum2 = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber; |
221 |
my $bibnum2 = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber; |
| 228 |
|
222 |
|
| 229 |
my ($itemnum_cpl, $itemnum_fpl); |
223 |
my ($itemnum_cpl, $itemnum_fpl); |
| 230 |
( undef, undef, $itemnum_cpl ) = AddItem( |
224 |
$itemnum_cpl = $builder->build_sample_item( |
| 231 |
{ homebranch => $branch_1, |
225 |
{ |
| 232 |
holdingbranch => $branch_1, |
226 |
biblionumber => $bibnum2, |
| 233 |
barcode => 'bug10272_CPL', |
227 |
library => $branch_1, |
| 234 |
itype => $itemtype |
228 |
barcode => 'bug10272_CPL', |
| 235 |
}, |
229 |
itype => $itemtype |
| 236 |
$bibnum2 |
230 |
} |
| 237 |
); |
231 |
)->itemnumber; |
| 238 |
( undef, undef, $itemnum_fpl ) = AddItem( |
232 |
$itemnum_fpl = $builder->build_sample_item( |
| 239 |
{ homebranch => $branch_2, |
233 |
{ |
| 240 |
holdingbranch => $branch_2, |
234 |
biblionumber => $bibnum2, |
| 241 |
barcode => 'bug10272_FPL', |
235 |
library => $branch_2, |
| 242 |
itype => $itemtype |
236 |
barcode => 'bug10272_FPL', |
| 243 |
}, |
237 |
itype => $itemtype |
| 244 |
$bibnum2 |
238 |
} |
| 245 |
); |
239 |
)->itemnumber; |
| 246 |
|
|
|
| 247 |
|
240 |
|
| 248 |
# Ensure that priorities are numbered correcly when a hold is moved to waiting |
241 |
# Ensure that priorities are numbered correcly when a hold is moved to waiting |
| 249 |
# (bug 11947) |
242 |
# (bug 11947) |
|
Lines 354-362
AddReserve(
Link Here
|
| 354 |
priority => 1, |
347 |
priority => 1, |
| 355 |
} |
348 |
} |
| 356 |
); |
349 |
); |
| 357 |
($status)=CheckReserves($itemnumber,undef,undef); |
350 |
($status)=CheckReserves($item->itemnumber,undef,undef); |
| 358 |
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead'); |
351 |
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead'); |
| 359 |
($status)=CheckReserves($itemnumber,undef,7); |
352 |
($status)=CheckReserves($item->itemnumber,undef,7); |
| 360 |
is( $status, 'Reserved', 'CheckReserves also returns reserve with lookahead'); |
353 |
is( $status, 'Reserved', 'CheckReserves also returns reserve with lookahead'); |
| 361 |
|
354 |
|
| 362 |
# Test 9761b: Add a reserve with future date, CheckReserve should not return it |
355 |
# Test 9761b: Add a reserve with future date, CheckReserve should not return it |
|
Lines 374-386
AddReserve(
Link Here
|
| 374 |
reservation_date => $resdate, |
367 |
reservation_date => $resdate, |
| 375 |
} |
368 |
} |
| 376 |
); |
369 |
); |
| 377 |
($status)=CheckReserves($itemnumber,undef,undef); |
370 |
($status)=CheckReserves($item->itemnumber,undef,undef); |
| 378 |
is( $status, '', 'CheckReserves returns no future reserve without lookahead'); |
371 |
is( $status, '', 'CheckReserves returns no future reserve without lookahead'); |
| 379 |
|
372 |
|
| 380 |
# Test 9761c: Add a reserve with future date, CheckReserve should return it if lookahead is high enough |
373 |
# Test 9761c: Add a reserve with future date, CheckReserve should return it if lookahead is high enough |
| 381 |
($status)=CheckReserves($itemnumber,undef,3); |
374 |
($status)=CheckReserves($item->itemnumber,undef,3); |
| 382 |
is( $status, '', 'CheckReserves returns no future reserve with insufficient lookahead'); |
375 |
is( $status, '', 'CheckReserves returns no future reserve with insufficient lookahead'); |
| 383 |
($status)=CheckReserves($itemnumber,undef,4); |
376 |
($status)=CheckReserves($item->itemnumber,undef,4); |
| 384 |
is( $status, 'Reserved', 'CheckReserves returns future reserve with sufficient lookahead'); |
377 |
is( $status, 'Reserved', 'CheckReserves returns future reserve with sufficient lookahead'); |
| 385 |
|
378 |
|
| 386 |
# Test 9761d: Check ResFound message of AddReturn for future hold |
379 |
# Test 9761d: Check ResFound message of AddReturn for future hold |
|
Lines 400-411
is(exists $messages->{ResFound}?1:0, 1, 'AddReturn considers future reserve with
Link Here
|
| 400 |
|
393 |
|
| 401 |
# test marking a hold as captured |
394 |
# test marking a hold as captured |
| 402 |
my $hold_notice_count = count_hold_print_messages(); |
395 |
my $hold_notice_count = count_hold_print_messages(); |
| 403 |
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0); |
396 |
ModReserveAffect($item->itemnumber, $requesters{$branch_1}, 0); |
| 404 |
my $new_count = count_hold_print_messages(); |
397 |
my $new_count = count_hold_print_messages(); |
| 405 |
is($new_count, $hold_notice_count + 1, 'patron notified when item set to waiting'); |
398 |
is($new_count, $hold_notice_count + 1, 'patron notified when item set to waiting'); |
| 406 |
|
399 |
|
| 407 |
# test that duplicate notices aren't generated |
400 |
# test that duplicate notices aren't generated |
| 408 |
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0); |
401 |
ModReserveAffect($item->itemnumber, $requesters{$branch_1}, 0); |
| 409 |
$new_count = count_hold_print_messages(); |
402 |
$new_count = count_hold_print_messages(); |
| 410 |
is($new_count, $hold_notice_count + 1, 'patron not notified a second time (bug 11445)'); |
403 |
is($new_count, $hold_notice_count + 1, 'patron not notified a second time (bug 11445)'); |
| 411 |
|
404 |
|
|
Lines 452-464
AddReserve(
Link Here
|
| 452 |
biblionumber => $bibnum, |
445 |
biblionumber => $bibnum, |
| 453 |
priority => 1, |
446 |
priority => 1, |
| 454 |
reservation_date => $resdate, |
447 |
reservation_date => $resdate, |
| 455 |
itemnumber => $itemnumber, |
448 |
itemnumber => $item->itemnumber, |
| 456 |
} |
449 |
} |
| 457 |
); #item level hold |
450 |
); #item level hold |
| 458 |
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); |
451 |
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); |
| 459 |
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); |
452 |
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); |
| 460 |
# 9788c: current_holds returns future wait (confirmed future hold) |
453 |
# 9788c: current_holds returns future wait (confirmed future hold) |
| 461 |
ModReserveAffect( $itemnumber, $requesters{$branch_1} , 0); #confirm hold |
454 |
ModReserveAffect( $item->itemnumber, $requesters{$branch_1} , 0); #confirm hold |
| 462 |
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); |
455 |
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); |
| 463 |
is( $future_holds->count, 1, 'current_holds returns a future wait (confirmed future hold)' ); |
456 |
is( $future_holds->count, 1, 'current_holds returns a future wait (confirmed future hold)' ); |
| 464 |
# End of tests for bug 9788 |
457 |
# End of tests for bug 9788 |
|
Lines 488-499
AddReserve(
Link Here
|
| 488 |
borrowernumber => $requesters{$branch_1}, |
481 |
borrowernumber => $requesters{$branch_1}, |
| 489 |
biblionumber => $bibnum, |
482 |
biblionumber => $bibnum, |
| 490 |
priority => $p, |
483 |
priority => $p, |
| 491 |
itemnumber => $itemnumber, |
484 |
itemnumber => $item->itemnumber, |
| 492 |
} |
485 |
} |
| 493 |
); |
486 |
); |
| 494 |
$p = C4::Reserves::CalculatePriority($bibnum); |
487 |
$p = C4::Reserves::CalculatePriority($bibnum); |
| 495 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
488 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
| 496 |
ModReserveAffect( $itemnumber, $requesters{$branch_1} , 0); |
489 |
ModReserveAffect( $item->itemnumber, $requesters{$branch_1} , 0); |
| 497 |
$p = C4::Reserves::CalculatePriority($bibnum); |
490 |
$p = C4::Reserves::CalculatePriority($bibnum); |
| 498 |
is($p, 1, 'CalculatePriority should now return priority 1'); |
491 |
is($p, 1, 'CalculatePriority should now return priority 1'); |
| 499 |
#add another biblio hold, no resdate |
492 |
#add another biblio hold, no resdate |
|
Lines 533-543
AddReserve(
Link Here
|
| 533 |
{ |
526 |
{ |
| 534 |
branchcode => $branch_1, |
527 |
branchcode => $branch_1, |
| 535 |
borrowernumber => $requesters{$branch_1}, |
528 |
borrowernumber => $requesters{$branch_1}, |
| 536 |
biblionumber => $item_bibnum, |
529 |
biblionumber => $bibnum, |
| 537 |
priority => 1, |
530 |
priority => 1, |
| 538 |
} |
531 |
} |
| 539 |
); |
532 |
); |
| 540 |
my (undef, $canres, undef) = CheckReserves($itemnumber); |
533 |
my (undef, $canres, undef) = CheckReserves($item->itemnumber); |
| 541 |
|
534 |
|
| 542 |
is( CanReserveBeCanceledFromOpac(), undef, |
535 |
is( CanReserveBeCanceledFromOpac(), undef, |
| 543 |
'CanReserveBeCanceledFromOpac should return undef if called without any parameter' |
536 |
'CanReserveBeCanceledFromOpac should return undef if called without any parameter' |
|
Lines 559-565
is($cancancel, 1, 'Can user cancel its own reserve');
Link Here
|
| 559 |
$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$branch_2}); |
552 |
$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$branch_2}); |
| 560 |
is($cancancel, 0, 'Other user cant cancel reserve'); |
553 |
is($cancancel, 0, 'Other user cant cancel reserve'); |
| 561 |
|
554 |
|
| 562 |
ModReserveAffect($itemnumber, $requesters{$branch_1}, 1); |
555 |
ModReserveAffect($item->itemnumber, $requesters{$branch_1}, 1); |
| 563 |
$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$branch_1}); |
556 |
$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$branch_1}); |
| 564 |
is($cancancel, 0, 'Reserve in transfer status cant be canceled'); |
557 |
is($cancancel, 0, 'Reserve in transfer status cant be canceled'); |
| 565 |
|
558 |
|
|
Lines 568-580
AddReserve(
Link Here
|
| 568 |
{ |
561 |
{ |
| 569 |
branchcode => $branch_1, |
562 |
branchcode => $branch_1, |
| 570 |
borrowernumber => $requesters{$branch_1}, |
563 |
borrowernumber => $requesters{$branch_1}, |
| 571 |
biblionumber => $item_bibnum, |
564 |
biblionumber => $bibnum, |
| 572 |
priority => 1, |
565 |
priority => 1, |
| 573 |
} |
566 |
} |
| 574 |
); |
567 |
); |
| 575 |
(undef, $canres, undef) = CheckReserves($itemnumber); |
568 |
(undef, $canres, undef) = CheckReserves($item->itemnumber); |
| 576 |
|
569 |
|
| 577 |
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0); |
570 |
ModReserveAffect($item->itemnumber, $requesters{$branch_1}, 0); |
| 578 |
$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$branch_1}); |
571 |
$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$branch_1}); |
| 579 |
is($cancancel, 0, 'Reserve in waiting status cant be canceled'); |
572 |
is($cancancel, 0, 'Reserve in waiting status cant be canceled'); |
| 580 |
|
573 |
|
|
Lines 613-620
is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblio_with_no_item->{bibl
Link Here
|
| 613 |
####### EO Bug 13113 <<< |
606 |
####### EO Bug 13113 <<< |
| 614 |
#### |
607 |
#### |
| 615 |
|
608 |
|
| 616 |
$item = Koha::Items->find($itemnumber); |
|
|
| 617 |
|
| 618 |
ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $patron), "Reserving a book on item level" ); |
609 |
ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $patron), "Reserving a book on item level" ); |
| 619 |
|
610 |
|
| 620 |
my $pickup_branch = $builder->build({ source => 'Branch' })->{ branchcode }; |
611 |
my $pickup_branch = $builder->build({ source => 'Branch' })->{ branchcode }; |
|
Lines 653-677
AddReserve(
Link Here
|
| 653 |
{ |
644 |
{ |
| 654 |
branchcode => $branch_1, |
645 |
branchcode => $branch_1, |
| 655 |
borrowernumber => $borrowernumber, |
646 |
borrowernumber => $borrowernumber, |
| 656 |
biblionumber => $item_bibnum, |
647 |
biblionumber => $bibnum, |
| 657 |
priority => 1, |
648 |
priority => 1, |
| 658 |
} |
649 |
} |
| 659 |
); |
650 |
); |
| 660 |
MoveReserve( $itemnumber, $borrowernumber ); |
651 |
MoveReserve( $item->itemnumber, $borrowernumber ); |
| 661 |
($status)=CheckReserves( $itemnumber ); |
652 |
($status)=CheckReserves( $item->itemnumber ); |
| 662 |
is( $status, '', 'MoveReserve filled hold'); |
653 |
is( $status, '', 'MoveReserve filled hold'); |
| 663 |
# hold from A waiting, today, no fut holds: MoveReserve should fill it |
654 |
# hold from A waiting, today, no fut holds: MoveReserve should fill it |
| 664 |
AddReserve( |
655 |
AddReserve( |
| 665 |
{ |
656 |
{ |
| 666 |
branchcode => $branch_1, |
657 |
branchcode => $branch_1, |
| 667 |
borrowernumber => $borrowernumber, |
658 |
borrowernumber => $borrowernumber, |
| 668 |
biblionumber => $item_bibnum, |
659 |
biblionumber => $bibnum, |
| 669 |
priority => 1, |
660 |
priority => 1, |
| 670 |
found => 'W', |
661 |
found => 'W', |
| 671 |
} |
662 |
} |
| 672 |
); |
663 |
); |
| 673 |
MoveReserve( $itemnumber, $borrowernumber ); |
664 |
MoveReserve( $item->itemnumber, $borrowernumber ); |
| 674 |
($status)=CheckReserves( $itemnumber ); |
665 |
($status)=CheckReserves( $item->itemnumber ); |
| 675 |
is( $status, '', 'MoveReserve filled waiting hold'); |
666 |
is( $status, '', 'MoveReserve filled waiting hold'); |
| 676 |
# hold from A pos 1, tomorrow, no fut holds: not filled |
667 |
# hold from A pos 1, tomorrow, no fut holds: not filled |
| 677 |
$resdate= dt_from_string(); |
668 |
$resdate= dt_from_string(); |
|
Lines 681-693
AddReserve(
Link Here
|
| 681 |
{ |
672 |
{ |
| 682 |
branchcode => $branch_1, |
673 |
branchcode => $branch_1, |
| 683 |
borrowernumber => $borrowernumber, |
674 |
borrowernumber => $borrowernumber, |
| 684 |
biblionumber => $item_bibnum, |
675 |
biblionumber => $bibnum, |
| 685 |
priority => 1, |
676 |
priority => 1, |
| 686 |
reservation_date => $resdate, |
677 |
reservation_date => $resdate, |
| 687 |
} |
678 |
} |
| 688 |
); |
679 |
); |
| 689 |
MoveReserve( $itemnumber, $borrowernumber ); |
680 |
MoveReserve( $item->itemnumber, $borrowernumber ); |
| 690 |
($status)=CheckReserves( $itemnumber, undef, 1 ); |
681 |
($status)=CheckReserves( $item->itemnumber, undef, 1 ); |
| 691 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold'); |
682 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold'); |
| 692 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
683 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
| 693 |
# hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it |
684 |
# hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it |
|
Lines 696-721
AddReserve(
Link Here
|
| 696 |
{ |
687 |
{ |
| 697 |
branchcode => $branch_1, |
688 |
branchcode => $branch_1, |
| 698 |
borrowernumber => $borrowernumber, |
689 |
borrowernumber => $borrowernumber, |
| 699 |
biblionumber => $item_bibnum, |
690 |
biblionumber => $bibnum, |
| 700 |
priority => 1, |
691 |
priority => 1, |
| 701 |
reservation_date => $resdate, |
692 |
reservation_date => $resdate, |
| 702 |
} |
693 |
} |
| 703 |
); |
694 |
); |
| 704 |
MoveReserve( $itemnumber, $borrowernumber ); |
695 |
MoveReserve( $item->itemnumber, $borrowernumber ); |
| 705 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
696 |
($status)=CheckReserves( $item->itemnumber, undef, 2 ); |
| 706 |
is( $status, '', 'MoveReserve filled future hold now'); |
697 |
is( $status, '', 'MoveReserve filled future hold now'); |
| 707 |
# hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it |
698 |
# hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it |
| 708 |
AddReserve( |
699 |
AddReserve( |
| 709 |
{ |
700 |
{ |
| 710 |
branchcode => $branch_1, |
701 |
branchcode => $branch_1, |
| 711 |
borrowernumber => $borrowernumber, |
702 |
borrowernumber => $borrowernumber, |
| 712 |
biblionumber => $item_bibnum, |
703 |
biblionumber => $bibnum, |
| 713 |
priority => 1, |
704 |
priority => 1, |
| 714 |
reservation_date => $resdate, |
705 |
reservation_date => $resdate, |
| 715 |
} |
706 |
} |
| 716 |
); |
707 |
); |
| 717 |
MoveReserve( $itemnumber, $borrowernumber ); |
708 |
MoveReserve( $item->itemnumber, $borrowernumber ); |
| 718 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
709 |
($status)=CheckReserves( $item->itemnumber, undef, 2 ); |
| 719 |
is( $status, '', 'MoveReserve filled future waiting hold now'); |
710 |
is( $status, '', 'MoveReserve filled future waiting hold now'); |
| 720 |
# hold from A pos 1, today+3, fut holds=2: MoveReserve should not fill it |
711 |
# hold from A pos 1, today+3, fut holds=2: MoveReserve should not fill it |
| 721 |
$resdate= dt_from_string(); |
712 |
$resdate= dt_from_string(); |
|
Lines 725-737
AddReserve(
Link Here
|
| 725 |
{ |
716 |
{ |
| 726 |
branchcode => $branch_1, |
717 |
branchcode => $branch_1, |
| 727 |
borrowernumber => $borrowernumber, |
718 |
borrowernumber => $borrowernumber, |
| 728 |
biblionumber => $item_bibnum, |
719 |
biblionumber => $bibnum, |
| 729 |
priority => 1, |
720 |
priority => 1, |
| 730 |
reservation_date => $resdate, |
721 |
reservation_date => $resdate, |
| 731 |
} |
722 |
} |
| 732 |
); |
723 |
); |
| 733 |
MoveReserve( $itemnumber, $borrowernumber ); |
724 |
MoveReserve( $item->itemnumber, $borrowernumber ); |
| 734 |
($status)=CheckReserves( $itemnumber, undef, 3 ); |
725 |
($status)=CheckReserves( $item->itemnumber, undef, 3 ); |
| 735 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
726 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
| 736 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
727 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
| 737 |
|
728 |
|