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