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 190-195
Koha::CirculationRules->set_rules(
Link Here
|
190 |
rules => { |
190 |
rules => { |
191 |
reservesallowed => 25, |
191 |
reservesallowed => 25, |
192 |
holds_per_record => 1, |
192 |
holds_per_record => 1, |
|
|
193 |
holds_per_day => 1, |
193 |
} |
194 |
} |
194 |
} |
195 |
} |
195 |
); |
196 |
); |
Lines 314-319
my $messages;
Link Here
|
314 |
# the one placed by the CPL patron, as the other two patron's hold |
315 |
# the one placed by the CPL patron, as the other two patron's hold |
315 |
# requests cannot be filled by that item per policy. |
316 |
# requests cannot be filled by that item per policy. |
316 |
(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2); |
317 |
(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2); |
|
|
318 |
|
317 |
is( $messages->{ResFound}->{borrowernumber}, |
319 |
is( $messages->{ResFound}->{borrowernumber}, |
318 |
$requesters{$branch_1}, |
320 |
$requesters{$branch_1}, |
319 |
'restrictive library\'s items only fill requests by own patrons (bug 10272)'); |
321 |
'restrictive library\'s items only fill requests by own patrons (bug 10272)'); |
Lines 725-730
MoveReserve( $item->itemnumber, $borrowernumber );
Link Here
|
725 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
727 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
726 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
728 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
727 |
|
729 |
|
|
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 |
#Test bug 23172. Check when returning an item that any patron category/item type combinations that forbid reservation are skipped over |
736 |
#when allocating the item to a bib-level hold |
737 |
$dbh->do('DELETE FROM issuingrules'); |
738 |
|
739 |
#Create two new patrons |
740 |
my $patronnumcat1 = Koha::Patron->new({branchcode => $branch_1, categorycode => $category_1})->store->borrowernumber; |
741 |
my $patronnumcat2 = Koha::Patron->new({branchcode => $branch_1, categorycode => $category_2})->store->borrowernumber; |
742 |
|
743 |
#Create a new biblio record |
744 |
my $bibnum3 = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber; |
745 |
|
746 |
#Create a second item type |
747 |
my $itemtype2 = $builder->build({ source => 'Itemtype', value => { notforloan => undef } } )->{itemtype}; |
748 |
|
749 |
# Create an item from new itemtype |
750 |
my ( $item_bibnum2, $item_bibitemnum2, $itemnumber2 ) = AddItem( |
751 |
{ homebranch => $branch_1, |
752 |
holdingbranch => $branch_1, |
753 |
itype => $itemtype2, |
754 |
barcode => 'bug23172_CPL' |
755 |
}, |
756 |
$bibnum3 |
757 |
); |
758 |
|
759 |
#Make a general All patron category/all item type rule |
760 |
$dbh->do( |
761 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
762 |
VALUES (?, ?, ?, ?, ?, ?)}, |
763 |
{}, |
764 |
'*', '*', '*', 25, 1, 1 |
765 |
); |
766 |
|
767 |
#When patron category = $category_1 and itemtype = $itemtype1 then reservesallowed, holds_per_day and holds_per_record are 0 |
768 |
$dbh->do( |
769 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
770 |
VALUES (?, ?, ?, ?, ?, ?)}, |
771 |
{}, |
772 |
$category_1, $branch_1, $itemtype2, 0, 1, 1 |
773 |
); |
774 |
|
775 |
#When patron category = $category_2 and itemtype = $itemtype2 then reservesallowed, holds_per_day and holds_per_record are 1 |
776 |
$dbh->do( |
777 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
778 |
VALUES (?, ?, ?, ?, ?, ?)}, |
779 |
{}, |
780 |
$category_2, $branch_1, $itemtype2, 1, 1, 1 |
781 |
); |
782 |
|
783 |
#Remove existing reserves |
784 |
$dbh->do("DELETE FROM reserves"); |
785 |
|
786 |
#Create Bib-level hold for borrower who has a patron category of $category_2 |
787 |
my $reserveid2 = AddReserve($branch_1, $patronnumcat2, $bibnum3); |
788 |
|
789 |
#Bib-level hold for borrower who has a patron category of $category_1 |
790 |
my $reserveid1 = AddReserve($branch_1, $patronnumcat1, $bibnum3 ); |
791 |
|
792 |
#Check bib-level hold priority and confirm hold made by patronnumcat1 (who fits into issuingrule with reserveallowed = 0) has first priority |
793 |
my $reserve1 = Koha::Holds->find($reserveid1); |
794 |
is( $reserve1->priority, 1, 'patronnumcat1 reserve is first priority'); |
795 |
|
796 |
my $reserve2 = Koha::Holds->find($reserveid2); |
797 |
is( $reserve2->priority, 2, 'patronnumcat2 reserve is second priority'); |
798 |
|
799 |
#Return the item |
800 |
(undef, $messages, undef, undef) = AddReturn('bug23172_CPL', $branch_1); |
801 |
|
802 |
#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 |
803 |
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)'); |
804 |
|
805 |
#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 |
806 |
$dbh->do(q{DELETE FROM issuingrules WHERE categorycode = ? AND branchcode = ? AND itemtype = ?}, |
807 |
{}, |
808 |
$category_1, $branch_1, $itemtype2 |
809 |
); |
810 |
$dbh->do( |
811 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_day, holds_per_record) |
812 |
VALUES (?, ?, ?, ?, ?, ?)}, |
813 |
{}, |
814 |
$category_1, $branch_1, $itemtype2, 1, 1, 1 |
815 |
); |
816 |
|
817 |
#Return the item again and notice this time it is allocated to the bib-level hold made by patronnumcat1 |
818 |
(undef, $messages, undef, undef) = AddReturn('bug23172_CPL', $branch_1); |
819 |
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)'); |
820 |
|
728 |
$cache->clear_from_cache("MarcStructure-0-$frameworkcode"); |
821 |
$cache->clear_from_cache("MarcStructure-0-$frameworkcode"); |
729 |
$cache->clear_from_cache("MarcStructure-1-$frameworkcode"); |
822 |
$cache->clear_from_cache("MarcStructure-1-$frameworkcode"); |
730 |
$cache->clear_from_cache("default_value_for_mod_marc-"); |
823 |
$cache->clear_from_cache("default_value_for_mod_marc-"); |
731 |
- |
|
|