|
Lines 8-14
Link Here
|
| 8 |
|
8 |
|
| 9 |
use Modern::Perl; |
9 |
use Modern::Perl; |
| 10 |
|
10 |
|
| 11 |
use Test::More tests => 53; |
11 |
use Test::More tests => 54; |
| 12 |
use Data::Dumper; |
12 |
use Data::Dumper; |
| 13 |
|
13 |
|
| 14 |
use C4::Calendar; |
14 |
use C4::Calendar; |
|
Lines 201-235
$library3 = $builder->build({
Link Here
|
| 201 |
}); |
201 |
}); |
| 202 |
@branchcodes = ( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode} ); |
202 |
@branchcodes = ( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode} ); |
| 203 |
|
203 |
|
|
|
204 |
my $category = $builder->build({ source => 'Category', value => {exclude_from_local_holds_priority => 0} } ); |
| 205 |
|
| 204 |
my $borrower1 = $builder->build({ |
206 |
my $borrower1 = $builder->build({ |
| 205 |
source => 'Borrower', |
207 |
source => 'Borrower', |
| 206 |
value => { |
208 |
value => { |
| 207 |
branchcode => $branchcodes[0], |
209 |
branchcode => $branchcodes[0], |
|
|
210 |
categorycode => $category->{categorycode}, |
| 208 |
}, |
211 |
}, |
| 209 |
}); |
212 |
}); |
| 210 |
my $borrower2 = $builder->build({ |
213 |
my $borrower2 = $builder->build({ |
| 211 |
source => 'Borrower', |
214 |
source => 'Borrower', |
| 212 |
value => { |
215 |
value => { |
| 213 |
branchcode => $branchcodes[1], |
216 |
branchcode => $branchcodes[1], |
|
|
217 |
categorycode => $category->{categorycode}, |
| 214 |
}, |
218 |
}, |
| 215 |
}); |
219 |
}); |
| 216 |
my $borrower3 = $builder->build({ |
220 |
my $borrower3 = $builder->build({ |
| 217 |
source => 'Borrower', |
221 |
source => 'Borrower', |
| 218 |
value => { |
222 |
value => { |
| 219 |
branchcode => $branchcodes[2], |
223 |
branchcode => $branchcodes[2], |
|
|
224 |
categorycode => $category->{categorycode}, |
| 220 |
}, |
225 |
}, |
| 221 |
}); |
226 |
}); |
| 222 |
|
227 |
|
| 223 |
$dbh->do(qq{ |
228 |
$dbh->do(qq{ |
| 224 |
INSERT INTO biblio ( |
229 |
INSERT INTO biblio ( |
| 225 |
frameworkcode, |
230 |
frameworkcode, |
| 226 |
author, |
231 |
author, |
| 227 |
title, |
232 |
title, |
| 228 |
datecreated |
233 |
datecreated |
| 229 |
) VALUES ( |
234 |
) VALUES ( |
| 230 |
'SER', |
235 |
'SER', |
| 231 |
'Koha test', |
236 |
'Koha test', |
| 232 |
'$TITLE', |
237 |
'$TITLE', |
| 233 |
'2011-02-01' |
238 |
'2011-02-01' |
| 234 |
) |
239 |
) |
| 235 |
}); |
240 |
}); |
|
Lines 238-247
$biblionumber = $dbh->selectrow_array("SELECT biblionumber FROM biblio WHERE tit
Link Here
|
| 238 |
|
243 |
|
| 239 |
$dbh->do(qq{ |
244 |
$dbh->do(qq{ |
| 240 |
INSERT INTO biblioitems ( |
245 |
INSERT INTO biblioitems ( |
| 241 |
biblionumber, |
246 |
biblionumber, |
| 242 |
itemtype |
247 |
itemtype |
| 243 |
) VALUES ( |
248 |
) VALUES ( |
| 244 |
$biblionumber, |
249 |
$biblionumber, |
| 245 |
'$itemtype' |
250 |
'$itemtype' |
| 246 |
) |
251 |
) |
| 247 |
}); |
252 |
}); |
|
Lines 250-256
$biblioitemnumber = $dbh->selectrow_array("SELECT biblioitemnumber FROM biblioit
Link Here
|
| 250 |
|
255 |
|
| 251 |
$items_insert_sth = $dbh->prepare(qq{ |
256 |
$items_insert_sth = $dbh->prepare(qq{ |
| 252 |
INSERT INTO items ( |
257 |
INSERT INTO items ( |
| 253 |
biblionumber, |
258 |
biblionumber, |
| 254 |
biblioitemnumber, |
259 |
biblioitemnumber, |
| 255 |
barcode, |
260 |
barcode, |
| 256 |
homebranch, |
261 |
homebranch, |
|
Lines 260-266
$items_insert_sth = $dbh->prepare(qq{
Link Here
|
| 260 |
itemlost, |
265 |
itemlost, |
| 261 |
withdrawn, |
266 |
withdrawn, |
| 262 |
onloan, |
267 |
onloan, |
| 263 |
itype |
268 |
itype, |
|
|
269 |
exclude_from_local_holds_priority |
| 264 |
) VALUES ( |
270 |
) VALUES ( |
| 265 |
$biblionumber, |
271 |
$biblionumber, |
| 266 |
$biblioitemnumber, |
272 |
$biblioitemnumber, |
|
Lines 272-278
$items_insert_sth = $dbh->prepare(qq{
Link Here
|
| 272 |
0, |
278 |
0, |
| 273 |
0, |
279 |
0, |
| 274 |
NULL, |
280 |
NULL, |
| 275 |
'$itemtype' |
281 |
'$itemtype', |
|
|
282 |
0 |
| 276 |
) |
283 |
) |
| 277 |
}); |
284 |
}); |
| 278 |
# Create 3 items from 2 branches ( branches are for borrowers 1 and 2 respectively ) |
285 |
# Create 3 items from 2 branches ( branches are for borrowers 1 and 2 respectively ) |
|
Lines 283-289
$items_insert_sth->execute( $barcode + 2, $branchcodes[1], $branchcodes[1] );
Link Here
|
| 283 |
|
290 |
|
| 284 |
$dbh->do("DELETE FROM reserves"); |
291 |
$dbh->do("DELETE FROM reserves"); |
| 285 |
my $sth = $dbh->prepare(q{ |
292 |
my $sth = $dbh->prepare(q{ |
| 286 |
INSERT INTO reserves ( |
293 |
INSERT INTO reserves ( |
| 287 |
borrowernumber, |
294 |
borrowernumber, |
| 288 |
biblionumber, |
295 |
biblionumber, |
| 289 |
branchcode, |
296 |
branchcode, |
|
Lines 516-528
$biblioitemnumber =
Link Here
|
| 516 |
or BAIL_OUT("Cannot find newly created biblioitems record"); |
523 |
or BAIL_OUT("Cannot find newly created biblioitems record"); |
| 517 |
|
524 |
|
| 518 |
$dbh->do(" |
525 |
$dbh->do(" |
| 519 |
INSERT INTO items (biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype) |
526 |
INSERT INTO items (biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype, exclude_from_local_holds_priority) |
| 520 |
VALUES ($biblionumber, $biblioitemnumber, '$library_A', '$library_A', 0, 0, 0, 0, NULL, '$itemtype') |
527 |
VALUES ($biblionumber, $biblioitemnumber, '$library_A', '$library_A', 0, 0, 0, 0, NULL, '$itemtype', 0) |
| 521 |
"); |
528 |
"); |
| 522 |
|
529 |
|
| 523 |
$dbh->do(" |
530 |
$dbh->do(" |
| 524 |
INSERT INTO items (biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype) |
531 |
INSERT INTO items (biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype, exclude_from_local_holds_priority) |
| 525 |
VALUES ($biblionumber, $biblioitemnumber, '$library_B', '$library_B', 0, 0, 0, 0, NULL, '$itemtype') |
532 |
VALUES ($biblionumber, $biblioitemnumber, '$library_B', '$library_B', 0, 0, 0, 0, NULL, '$itemtype', 0) |
| 526 |
"); |
533 |
"); |
| 527 |
|
534 |
|
| 528 |
Koha::CirculationRules->set_rules( |
535 |
Koha::CirculationRules->set_rules( |
|
Lines 587-594
$biblioitemnumber =
Link Here
|
| 587 |
or BAIL_OUT("Cannot find newly created biblioitems record"); |
594 |
or BAIL_OUT("Cannot find newly created biblioitems record"); |
| 588 |
|
595 |
|
| 589 |
$dbh->do(" |
596 |
$dbh->do(" |
| 590 |
INSERT INTO items (biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype) |
597 |
INSERT INTO items (biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype, exclude_from_local_holds_priority) |
| 591 |
VALUES ($biblionumber, $biblioitemnumber, '$library_A', '$library_A', 0, 0, 0, 0, NULL, '$itemtype') |
598 |
VALUES ($biblionumber, $biblioitemnumber, '$library_A', '$library_A', 0, 0, 0, 0, NULL, '$itemtype', 0) |
| 592 |
"); |
599 |
"); |
| 593 |
|
600 |
|
| 594 |
$reserve_id = AddReserve( |
601 |
$reserve_id = AddReserve( |
|
Lines 632-639
$biblioitemnumber =
Link Here
|
| 632 |
or BAIL_OUT("Cannot find newly created biblioitems record"); |
639 |
or BAIL_OUT("Cannot find newly created biblioitems record"); |
| 633 |
|
640 |
|
| 634 |
$dbh->do(" |
641 |
$dbh->do(" |
| 635 |
INSERT INTO items (biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype) |
642 |
INSERT INTO items (biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype, exclude_from_local_holds_priority) |
| 636 |
VALUES ($biblionumber, $biblioitemnumber, '$library_A', '$library_B', 0, 0, 0, 0, NULL, '$itemtype') |
643 |
VALUES ($biblionumber, $biblioitemnumber, '$library_A', '$library_B', 0, 0, 0, 0, NULL, '$itemtype', 0) |
| 637 |
"); |
644 |
"); |
| 638 |
|
645 |
|
| 639 |
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch |
646 |
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch |
|
Lines 840-847
$biblioitemnumber =
Link Here
|
| 840 |
or BAIL_OUT("Cannot find newly created biblioitems record"); |
847 |
or BAIL_OUT("Cannot find newly created biblioitems record"); |
| 841 |
|
848 |
|
| 842 |
$dbh->do(" |
849 |
$dbh->do(" |
| 843 |
INSERT INTO items (biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype) |
850 |
INSERT INTO items (biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype, exclude_from_local_holds_priority) |
| 844 |
VALUES ($biblionumber, $biblioitemnumber, '$library_A', '$library_B', 0, 0, 0, 0, NULL, '$right_itemtype') |
851 |
VALUES ($biblionumber, $biblioitemnumber, '$library_A', '$library_B', 0, 0, 0, 0, NULL, '$right_itemtype', 0) |
| 845 |
"); |
852 |
"); |
| 846 |
|
853 |
|
| 847 |
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch |
854 |
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch |
|
Lines 916-926
subtest "Test Local Holds Priority - Bib level" => sub {
Link Here
|
| 916 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
923 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
| 917 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
924 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 918 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
925 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
|
|
926 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} }); |
| 919 |
my $local_patron = $builder->build_object( |
927 |
my $local_patron = $builder->build_object( |
| 920 |
{ |
928 |
{ |
| 921 |
class => "Koha::Patrons", |
929 |
class => "Koha::Patrons", |
| 922 |
value => { |
930 |
value => { |
| 923 |
branchcode => $branch->branchcode |
931 |
branchcode => $branch->branchcode, |
|
|
932 |
categorycode => $category->categorycode |
| 924 |
} |
933 |
} |
| 925 |
} |
934 |
} |
| 926 |
); |
935 |
); |
|
Lines 928-934
subtest "Test Local Holds Priority - Bib level" => sub {
Link Here
|
| 928 |
{ |
937 |
{ |
| 929 |
class => "Koha::Patrons", |
938 |
class => "Koha::Patrons", |
| 930 |
value => { |
939 |
value => { |
| 931 |
branchcode => $branch2->branchcode |
940 |
branchcode => $branch2->branchcode, |
|
|
941 |
categorycode => $category->categorycode |
| 932 |
} |
942 |
} |
| 933 |
} |
943 |
} |
| 934 |
); |
944 |
); |
|
Lines 937-942
subtest "Test Local Holds Priority - Bib level" => sub {
Link Here
|
| 937 |
{ |
947 |
{ |
| 938 |
biblionumber => $biblio->biblionumber, |
948 |
biblionumber => $biblio->biblionumber, |
| 939 |
library => $branch->branchcode, |
949 |
library => $branch->branchcode, |
|
|
950 |
exclude_from_local_holds_priority => 0, |
| 940 |
} |
951 |
} |
| 941 |
); |
952 |
); |
| 942 |
|
953 |
|
|
Lines 978-988
subtest "Test Local Holds Priority - Item level" => sub {
Link Here
|
| 978 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
989 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
| 979 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
990 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 980 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
991 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
|
|
992 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} }); |
| 981 |
my $local_patron = $builder->build_object( |
993 |
my $local_patron = $builder->build_object( |
| 982 |
{ |
994 |
{ |
| 983 |
class => "Koha::Patrons", |
995 |
class => "Koha::Patrons", |
| 984 |
value => { |
996 |
value => { |
| 985 |
branchcode => $branch->branchcode |
997 |
branchcode => $branch->branchcode, |
|
|
998 |
categorycode => $category->categorycode |
| 986 |
} |
999 |
} |
| 987 |
} |
1000 |
} |
| 988 |
); |
1001 |
); |
|
Lines 990-996
subtest "Test Local Holds Priority - Item level" => sub {
Link Here
|
| 990 |
{ |
1003 |
{ |
| 991 |
class => "Koha::Patrons", |
1004 |
class => "Koha::Patrons", |
| 992 |
value => { |
1005 |
value => { |
| 993 |
branchcode => $branch2->branchcode |
1006 |
branchcode => $branch2->branchcode, |
|
|
1007 |
categorycode => $category->categorycode |
| 994 |
} |
1008 |
} |
| 995 |
} |
1009 |
} |
| 996 |
); |
1010 |
); |
|
Lines 999-1004
subtest "Test Local Holds Priority - Item level" => sub {
Link Here
|
| 999 |
{ |
1013 |
{ |
| 1000 |
biblionumber => $biblio->biblionumber, |
1014 |
biblionumber => $biblio->biblionumber, |
| 1001 |
library => $branch->branchcode, |
1015 |
library => $branch->branchcode, |
|
|
1016 |
exclude_from_local_holds_priority => 0, |
| 1002 |
} |
1017 |
} |
| 1003 |
); |
1018 |
); |
| 1004 |
|
1019 |
|
|
Lines 1043-1053
subtest "Test Local Holds Priority - Item level hold over Record level hold (Bug
Link Here
|
| 1043 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
1058 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
| 1044 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
1059 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1045 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1060 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
|
|
1061 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} }); |
| 1046 |
my $local_patron = $builder->build_object( |
1062 |
my $local_patron = $builder->build_object( |
| 1047 |
{ |
1063 |
{ |
| 1048 |
class => "Koha::Patrons", |
1064 |
class => "Koha::Patrons", |
| 1049 |
value => { |
1065 |
value => { |
| 1050 |
branchcode => $branch->branchcode |
1066 |
branchcode => $branch->branchcode, |
|
|
1067 |
categorycode => $category->categorycode, |
| 1051 |
} |
1068 |
} |
| 1052 |
} |
1069 |
} |
| 1053 |
); |
1070 |
); |
|
Lines 1055-1061
subtest "Test Local Holds Priority - Item level hold over Record level hold (Bug
Link Here
|
| 1055 |
{ |
1072 |
{ |
| 1056 |
class => "Koha::Patrons", |
1073 |
class => "Koha::Patrons", |
| 1057 |
value => { |
1074 |
value => { |
| 1058 |
branchcode => $branch2->branchcode |
1075 |
branchcode => $branch2->branchcode, |
|
|
1076 |
categorycode => $category->categorycode, |
| 1059 |
} |
1077 |
} |
| 1060 |
} |
1078 |
} |
| 1061 |
); |
1079 |
); |
|
Lines 1064-1069
subtest "Test Local Holds Priority - Item level hold over Record level hold (Bug
Link Here
|
| 1064 |
{ |
1082 |
{ |
| 1065 |
biblionumber => $biblio->biblionumber, |
1083 |
biblionumber => $biblio->biblionumber, |
| 1066 |
library => $branch->branchcode, |
1084 |
library => $branch->branchcode, |
|
|
1085 |
exclude_from_local_holds_priority => 0, |
| 1067 |
} |
1086 |
} |
| 1068 |
); |
1087 |
); |
| 1069 |
|
1088 |
|
|
Lines 1107-1117
subtest "Test Local Holds Priority - Get correct item for item level hold" => su
Link Here
|
| 1107 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
1126 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
| 1108 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
1127 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1109 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1128 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
|
|
1129 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} }); |
| 1110 |
my $local_patron = $builder->build_object( |
1130 |
my $local_patron = $builder->build_object( |
| 1111 |
{ |
1131 |
{ |
| 1112 |
class => "Koha::Patrons", |
1132 |
class => "Koha::Patrons", |
| 1113 |
value => { |
1133 |
value => { |
| 1114 |
branchcode => $branch->branchcode |
1134 |
branchcode => $branch->branchcode, |
|
|
1135 |
categorycode => $category->categorycode, |
| 1115 |
} |
1136 |
} |
| 1116 |
} |
1137 |
} |
| 1117 |
); |
1138 |
); |
|
Lines 1119-1125
subtest "Test Local Holds Priority - Get correct item for item level hold" => su
Link Here
|
| 1119 |
{ |
1140 |
{ |
| 1120 |
class => "Koha::Patrons", |
1141 |
class => "Koha::Patrons", |
| 1121 |
value => { |
1142 |
value => { |
| 1122 |
branchcode => $branch2->branchcode |
1143 |
branchcode => $branch2->branchcode, |
|
|
1144 |
categorycode => $category->categorycode, |
| 1123 |
} |
1145 |
} |
| 1124 |
} |
1146 |
} |
| 1125 |
); |
1147 |
); |
|
Lines 1129-1146
subtest "Test Local Holds Priority - Get correct item for item level hold" => su
Link Here
|
| 1129 |
{ |
1151 |
{ |
| 1130 |
biblionumber => $biblio->biblionumber, |
1152 |
biblionumber => $biblio->biblionumber, |
| 1131 |
library => $branch->branchcode, |
1153 |
library => $branch->branchcode, |
|
|
1154 |
exclude_from_local_holds_priority => 0, |
| 1132 |
} |
1155 |
} |
| 1133 |
); |
1156 |
); |
| 1134 |
my $item2 = $builder->build_sample_item( |
1157 |
my $item2 = $builder->build_sample_item( |
| 1135 |
{ |
1158 |
{ |
| 1136 |
biblionumber => $biblio->biblionumber, |
1159 |
biblionumber => $biblio->biblionumber, |
| 1137 |
library => $branch->branchcode, |
1160 |
library => $branch->branchcode, |
|
|
1161 |
exclude_from_local_holds_priority => 0, |
| 1138 |
} |
1162 |
} |
| 1139 |
); |
1163 |
); |
| 1140 |
my $item3 = $builder->build_sample_item( |
1164 |
my $item3 = $builder->build_sample_item( |
| 1141 |
{ |
1165 |
{ |
| 1142 |
biblionumber => $biblio->biblionumber, |
1166 |
biblionumber => $biblio->biblionumber, |
| 1143 |
library => $branch->branchcode, |
1167 |
library => $branch->branchcode, |
|
|
1168 |
exclude_from_local_holds_priority => 0, |
| 1144 |
} |
1169 |
} |
| 1145 |
); |
1170 |
); |
| 1146 |
|
1171 |
|
|
Lines 1184-1194
subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue
Link Here
|
| 1184 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
1209 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
| 1185 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
1210 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1186 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1211 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
|
|
1212 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} }); |
| 1187 |
my $patron = $builder->build_object( |
1213 |
my $patron = $builder->build_object( |
| 1188 |
{ |
1214 |
{ |
| 1189 |
class => "Koha::Patrons", |
1215 |
class => "Koha::Patrons", |
| 1190 |
value => { |
1216 |
value => { |
| 1191 |
branchcode => $branch->branchcode |
1217 |
branchcode => $branch->branchcode, |
|
|
1218 |
categorycode => $category->categorycode, |
| 1192 |
} |
1219 |
} |
| 1193 |
} |
1220 |
} |
| 1194 |
); |
1221 |
); |
|
Lines 1197-1208
subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue
Link Here
|
| 1197 |
{ |
1224 |
{ |
| 1198 |
biblionumber => $biblio->biblionumber, |
1225 |
biblionumber => $biblio->biblionumber, |
| 1199 |
library => $branch->branchcode, |
1226 |
library => $branch->branchcode, |
|
|
1227 |
exclude_from_local_holds_priority => 0, |
| 1200 |
} |
1228 |
} |
| 1201 |
); |
1229 |
); |
| 1202 |
my $item2 = $builder->build_sample_item( |
1230 |
my $item2 = $builder->build_sample_item( |
| 1203 |
{ |
1231 |
{ |
| 1204 |
biblionumber => $biblio->biblionumber, |
1232 |
biblionumber => $biblio->biblionumber, |
| 1205 |
library => $branch->branchcode, |
1233 |
library => $branch->branchcode, |
|
|
1234 |
exclude_from_local_holds_priority => 0, |
| 1206 |
} |
1235 |
} |
| 1207 |
); |
1236 |
); |
| 1208 |
|
1237 |
|
|
Lines 1210-1215
subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue
Link Here
|
| 1210 |
{ |
1239 |
{ |
| 1211 |
biblionumber => $biblio->biblionumber, |
1240 |
biblionumber => $biblio->biblionumber, |
| 1212 |
library => $branch->branchcode, |
1241 |
library => $branch->branchcode, |
|
|
1242 |
exclude_from_local_holds_priority => 0, |
| 1213 |
} |
1243 |
} |
| 1214 |
); |
1244 |
); |
| 1215 |
|
1245 |
|
|
Lines 1241-1251
subtest "Item level holds info is preserved (Bug 25738)" => sub {
Link Here
|
| 1241 |
$dbh->do("DELETE FROM circulation_rules"); |
1271 |
$dbh->do("DELETE FROM circulation_rules"); |
| 1242 |
|
1272 |
|
| 1243 |
my $library = $builder->build_object({ class => 'Koha::Libraries' }); |
1273 |
my $library = $builder->build_object({ class => 'Koha::Libraries' }); |
|
|
1274 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} }); |
| 1244 |
my $patron_1 = $builder->build_object( |
1275 |
my $patron_1 = $builder->build_object( |
| 1245 |
{ |
1276 |
{ |
| 1246 |
class => "Koha::Patrons", |
1277 |
class => "Koha::Patrons", |
| 1247 |
value => { |
1278 |
value => { |
| 1248 |
branchcode => $library->branchcode |
1279 |
branchcode => $library->branchcode, |
|
|
1280 |
categorycode => $category->categorycode |
| 1249 |
} |
1281 |
} |
| 1250 |
} |
1282 |
} |
| 1251 |
); |
1283 |
); |
|
Lines 1254-1260
subtest "Item level holds info is preserved (Bug 25738)" => sub {
Link Here
|
| 1254 |
{ |
1286 |
{ |
| 1255 |
class => "Koha::Patrons", |
1287 |
class => "Koha::Patrons", |
| 1256 |
value => { |
1288 |
value => { |
| 1257 |
branchcode => $library->branchcode |
1289 |
branchcode => $library->branchcode, |
|
|
1290 |
categorycode => $category->categorycode |
| 1258 |
} |
1291 |
} |
| 1259 |
} |
1292 |
} |
| 1260 |
); |
1293 |
); |
|
Lines 1264-1275
subtest "Item level holds info is preserved (Bug 25738)" => sub {
Link Here
|
| 1264 |
{ |
1297 |
{ |
| 1265 |
biblionumber => $biblio->biblionumber, |
1298 |
biblionumber => $biblio->biblionumber, |
| 1266 |
library => $library->branchcode, |
1299 |
library => $library->branchcode, |
|
|
1300 |
exclude_from_local_holds_priority => 0, |
| 1267 |
} |
1301 |
} |
| 1268 |
); |
1302 |
); |
| 1269 |
my $item_2 = $builder->build_sample_item( |
1303 |
my $item_2 = $builder->build_sample_item( |
| 1270 |
{ |
1304 |
{ |
| 1271 |
biblionumber => $biblio->biblionumber, |
1305 |
biblionumber => $biblio->biblionumber, |
| 1272 |
library => $library->branchcode, |
1306 |
library => $library->branchcode, |
|
|
1307 |
exclude_from_local_holds_priority => 0, |
| 1273 |
} |
1308 |
} |
| 1274 |
); |
1309 |
); |
| 1275 |
|
1310 |
|
|
Lines 1317-1322
subtest 'Trivial test for UpdateTransportCostMatrix' => sub {
Link Here
|
| 1317 |
is( $schema->resultset('TransportCost')->count, 2, 'UpdateTransportCostMatrix added two records' ); |
1352 |
is( $schema->resultset('TransportCost')->count, 2, 'UpdateTransportCostMatrix added two records' ); |
| 1318 |
}; |
1353 |
}; |
| 1319 |
|
1354 |
|
|
|
1355 |
subtest 'Excludes from local holds priority' => sub { |
| 1356 |
plan tests => 5; |
| 1357 |
|
| 1358 |
Koha::Holds->delete; |
| 1359 |
|
| 1360 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 1 ); |
| 1361 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityPatronControl', 'PickupLibrary' ); |
| 1362 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
| 1363 |
|
| 1364 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1365 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1366 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} }); |
| 1367 |
my $excluded_category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 1} }); |
| 1368 |
my $local_patron_excluded = $builder->build_object( |
| 1369 |
{ |
| 1370 |
class => "Koha::Patrons", |
| 1371 |
value => { |
| 1372 |
branchcode => $branch->branchcode, |
| 1373 |
categorycode => $excluded_category->categorycode |
| 1374 |
} |
| 1375 |
} |
| 1376 |
); |
| 1377 |
|
| 1378 |
my $local_patron_not_excluded = $builder->build_object( |
| 1379 |
{ |
| 1380 |
class => "Koha::Patrons", |
| 1381 |
value => { |
| 1382 |
branchcode => $branch->branchcode, |
| 1383 |
categorycode => $category->categorycode |
| 1384 |
} |
| 1385 |
} |
| 1386 |
); |
| 1387 |
|
| 1388 |
my $other_patron = $builder->build_object( |
| 1389 |
{ |
| 1390 |
class => "Koha::Patrons", |
| 1391 |
value => { |
| 1392 |
branchcode => $branch2->branchcode, |
| 1393 |
categorycode => $category->categorycode |
| 1394 |
} |
| 1395 |
} |
| 1396 |
); |
| 1397 |
|
| 1398 |
my $item1 = $builder->build_sample_item( |
| 1399 |
{ |
| 1400 |
library => $branch->branchcode, |
| 1401 |
exclude_from_local_holds_priority => 0, |
| 1402 |
} |
| 1403 |
); |
| 1404 |
|
| 1405 |
AddReserve( |
| 1406 |
{ |
| 1407 |
branchcode => $other_patron->branchcode, |
| 1408 |
borrowernumber => $other_patron->borrowernumber, |
| 1409 |
biblionumber => $item1->biblionumber, |
| 1410 |
priority => 1 |
| 1411 |
} |
| 1412 |
); |
| 1413 |
|
| 1414 |
AddReserve( |
| 1415 |
{ |
| 1416 |
branchcode => $local_patron_excluded->branchcode, |
| 1417 |
borrowernumber => $local_patron_excluded->borrowernumber, |
| 1418 |
biblionumber => $item1->biblionumber, |
| 1419 |
priority => 2 |
| 1420 |
} |
| 1421 |
); |
| 1422 |
|
| 1423 |
AddReserve( |
| 1424 |
{ |
| 1425 |
branchcode => $local_patron_not_excluded->branchcode, |
| 1426 |
borrowernumber => $local_patron_not_excluded->borrowernumber, |
| 1427 |
biblionumber => $item1->biblionumber, |
| 1428 |
priority => 3 |
| 1429 |
} |
| 1430 |
); |
| 1431 |
|
| 1432 |
C4::HoldsQueue::CreateQueue(); |
| 1433 |
|
| 1434 |
my $queue_rs = $schema->resultset('TmpHoldsqueue'); |
| 1435 |
my $next = $queue_rs->next; |
| 1436 |
is($next->borrowernumber, $local_patron_not_excluded->borrowernumber, 'Not excluded local patron is queued'); |
| 1437 |
|
| 1438 |
my $item2 = $builder->build_sample_item( |
| 1439 |
{ |
| 1440 |
biblionumber => $item1->biblionumber, |
| 1441 |
library => $branch->branchcode, |
| 1442 |
exclude_from_local_holds_priority => 1, |
| 1443 |
} |
| 1444 |
); |
| 1445 |
C4::HoldsQueue::CreateQueue(); |
| 1446 |
|
| 1447 |
$queue_rs = $schema->resultset('TmpHoldsqueue'); |
| 1448 |
$next = $queue_rs->next; |
| 1449 |
is($next->borrowernumber, $local_patron_not_excluded->borrowernumber, 'Not excluded local patron is queued'); |
| 1450 |
$next = $queue_rs->next; |
| 1451 |
is($next->borrowernumber, $other_patron->borrowernumber, 'Other patron is queued'); |
| 1452 |
|
| 1453 |
$item1->exclude_from_local_holds_priority(1)->store; |
| 1454 |
|
| 1455 |
C4::HoldsQueue::CreateQueue(); |
| 1456 |
|
| 1457 |
$queue_rs = $schema->resultset('TmpHoldsqueue'); |
| 1458 |
$next = $queue_rs->next; |
| 1459 |
is($next->borrowernumber, $other_patron->borrowernumber, 'Other patron is queued'); |
| 1460 |
$next = $queue_rs->next; |
| 1461 |
is($next->borrowernumber, $local_patron_excluded->borrowernumber, 'Excluded local patron is queued'); |
| 1462 |
}; |
| 1320 |
# Cleanup |
1463 |
# Cleanup |
| 1321 |
$schema->storage->txn_rollback; |
1464 |
$schema->storage->txn_rollback; |
| 1322 |
|
1465 |
|
| 1323 |
- |
|
|