Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 62; |
20 |
use Test::More tests => 65; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
Lines 192-201
$requesters{$branch_3} = Koha::Patron->new({
Link Here
|
192 |
|
192 |
|
193 |
$dbh->do('DELETE FROM issuingrules'); |
193 |
$dbh->do('DELETE FROM issuingrules'); |
194 |
$dbh->do( |
194 |
$dbh->do( |
195 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) |
195 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record, holds_per_day) |
196 |
VALUES (?, ?, ?, ?)}, |
196 |
VALUES (?, ?, ?, ?, ?, ?)}, |
197 |
{}, |
197 |
{}, |
198 |
'*', '*', '*', 25 |
198 |
'*', '*', '*', 25, 1, 1 |
199 |
); |
199 |
); |
200 |
|
200 |
|
201 |
# CPL allows only its own patrons to request its items |
201 |
# CPL allows only its own patrons to request its items |
Lines 290-295
my $messages;
Link Here
|
290 |
# the one placed by the CPL patron, as the other two patron's hold |
290 |
# the one placed by the CPL patron, as the other two patron's hold |
291 |
# requests cannot be filled by that item per policy. |
291 |
# requests cannot be filled by that item per policy. |
292 |
(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2); |
292 |
(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2); |
|
|
293 |
|
293 |
is( $messages->{ResFound}->{borrowernumber}, |
294 |
is( $messages->{ResFound}->{borrowernumber}, |
294 |
$requesters{$branch_1}, |
295 |
$requesters{$branch_1}, |
295 |
'restrictive library\'s items only fill requests by own patrons (bug 10272)'); |
296 |
'restrictive library\'s items only fill requests by own patrons (bug 10272)'); |
Lines 596-601
MoveReserve( $itemnumber, $borrowernumber );
Link Here
|
596 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
597 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
597 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
598 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
598 |
|
599 |
|
|
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
#Test bug 23172. Check when returning an item that any patron category/item type combinations that forbid reservation are skipped over |
606 |
#when allocating the item to a bib-level hold |
607 |
$dbh->do('DELETE FROM issuingrules'); |
608 |
|
609 |
#Create two new patrons |
610 |
my $patronnumcat1 = Koha::Patron->new({branchcode => $branch_1, categorycode => $category_1})->store->borrowernumber; |
611 |
my $patronnumcat2 = Koha::Patron->new({branchcode => $branch_1, categorycode => $category_2})->store->borrowernumber; |
612 |
|
613 |
#Create a new biblio record |
614 |
my $bibnum3 = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber; |
615 |
|
616 |
#Create a second item type |
617 |
my $itemtype2 = $builder->build({ source => 'Itemtype', value => { notforloan => undef } } )->{itemtype}; |
618 |
|
619 |
# Create an item from new itemtype |
620 |
my ( $item_bibnum2, $item_bibitemnum2, $itemnumber2 ) = AddItem( |
621 |
{ homebranch => $branch_1, |
622 |
holdingbranch => $branch_1, |
623 |
itype => $itemtype2, |
624 |
barcode => 'bug23172_CPL' |
625 |
}, |
626 |
$bibnum3 |
627 |
); |
628 |
|
629 |
#Make a general All patron category/all item type rule |
630 |
$dbh->do( |
631 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
632 |
VALUES (?, ?, ?, ?, ?, ?)}, |
633 |
{}, |
634 |
'*', '*', '*', 25, 1, 1 |
635 |
); |
636 |
|
637 |
#When patron category = $category_1 and itemtype = $itemtype1 then reservesallowed, holds_per_day and holds_per_record are 0 |
638 |
$dbh->do( |
639 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
640 |
VALUES (?, ?, ?, ?, ?, ?)}, |
641 |
{}, |
642 |
$category_1, $branch_1, $itemtype2, 0, 1, 1 |
643 |
); |
644 |
|
645 |
#When patron category = $category_2 and itemtype = $itemtype2 then reservesallowed, holds_per_day and holds_per_record are 1 |
646 |
$dbh->do( |
647 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
648 |
VALUES (?, ?, ?, ?, ?, ?)}, |
649 |
{}, |
650 |
$category_2, $branch_1, $itemtype2, 1, 1, 1 |
651 |
); |
652 |
|
653 |
#Remove existing reserves |
654 |
$dbh->do("DELETE FROM reserves"); |
655 |
|
656 |
#Create Bib-level hold for borrower who has a patron category of $category_2 |
657 |
my $reserveid2 = AddReserve($branch_1, $patronnumcat2, $bibnum3); |
658 |
|
659 |
#Bib-level hold for borrower who has a patron category of $category_1 |
660 |
my $reserveid1 = AddReserve($branch_1, $patronnumcat1, $bibnum3 ); |
661 |
|
662 |
#Check bib-level hold priority and confirm hold made by patronnumcat1 (who fits into issuingrule with reserveallowed = 0) has first priority |
663 |
my $reserve1 = Koha::Holds->find($reserveid1); |
664 |
is( $reserve1->priority, 1, 'patronnumcat1 reserve is first priority'); |
665 |
|
666 |
my $reserve2 = Koha::Holds->find($reserveid2); |
667 |
is( $reserve2->priority, 2, 'patronnumcat2 reserve is second priority'); |
668 |
|
669 |
#Return the item |
670 |
(undef, $messages, undef, undef) = AddReturn('bug23172_CPL', $branch_1); |
671 |
|
672 |
#First priority hold is skipped as issuingrule is checked and the first hold does not respect issuingrules (as one of the three fields: reservesallowed, holds_per_day is 0) therefore not allocating item to this bib-level hold |
673 |
is( $messages->{ResFound}->{borrowernumber}, $patronnumcat2,'Skip allocating item to first priority hold as it does not respect issuingrules instead allocate to next valid hold (bug 23172)'); |
674 |
|
675 |
#Remove and re-add the issuing rule that prevented patronnumcat1 bib-level hold from being allocated upon item return making reservesallowed, holds_per_day and holds_per_record > 0 |
676 |
$dbh->do(q{DELETE FROM issuingrules WHERE categorycode = ? AND branchcode = ? AND itemtype = ?}, |
677 |
{}, |
678 |
$category_1, $branch_1, $itemtype2 |
679 |
); |
680 |
$dbh->do( |
681 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
682 |
VALUES (?, ?, ?, ?, ?, ?)}, |
683 |
{}, |
684 |
$category_1, $branch_1, $itemtype2, 1, 1, 1 |
685 |
); |
686 |
|
687 |
#Return the item again and notice this time it is allocated to the bib-level hold made by patronnumcat1 |
688 |
(undef, $messages, undef, undef) = AddReturn('bug23172_CPL', $branch_1); |
689 |
is( $messages->{ResFound}->{borrowernumber}, $patronnumcat1,'Skip allocating item to first priority hold as it does not respect issuingrules instead allocate to next valid hold (bug 23172)'); |
690 |
|
599 |
$cache->clear_from_cache("MarcStructure-0-$frameworkcode"); |
691 |
$cache->clear_from_cache("MarcStructure-0-$frameworkcode"); |
600 |
$cache->clear_from_cache("MarcStructure-1-$frameworkcode"); |
692 |
$cache->clear_from_cache("MarcStructure-1-$frameworkcode"); |
601 |
$cache->clear_from_cache("default_value_for_mod_marc-"); |
693 |
$cache->clear_from_cache("default_value_for_mod_marc-"); |
602 |
- |
|
|