Lines 8-14
Link Here
|
8 |
|
8 |
|
9 |
use Modern::Perl; |
9 |
use Modern::Perl; |
10 |
|
10 |
|
11 |
use Test::More tests => 51; |
11 |
use Test::More tests => 52; |
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 1112-1122
subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue
Link Here
|
1112 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
1131 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
1113 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
1132 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
1114 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1133 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
|
|
1134 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} }); |
1115 |
my $patron = $builder->build_object( |
1135 |
my $patron = $builder->build_object( |
1116 |
{ |
1136 |
{ |
1117 |
class => "Koha::Patrons", |
1137 |
class => "Koha::Patrons", |
1118 |
value => { |
1138 |
value => { |
1119 |
branchcode => $branch->branchcode |
1139 |
branchcode => $branch->branchcode, |
|
|
1140 |
categorycode => $category->categorycode, |
1120 |
} |
1141 |
} |
1121 |
} |
1142 |
} |
1122 |
); |
1143 |
); |
Lines 1125-1136
subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue
Link Here
|
1125 |
{ |
1146 |
{ |
1126 |
biblionumber => $biblio->biblionumber, |
1147 |
biblionumber => $biblio->biblionumber, |
1127 |
library => $branch->branchcode, |
1148 |
library => $branch->branchcode, |
|
|
1149 |
exclude_from_local_holds_priority => 0, |
1128 |
} |
1150 |
} |
1129 |
); |
1151 |
); |
1130 |
my $item2 = $builder->build_sample_item( |
1152 |
my $item2 = $builder->build_sample_item( |
1131 |
{ |
1153 |
{ |
1132 |
biblionumber => $biblio->biblionumber, |
1154 |
biblionumber => $biblio->biblionumber, |
1133 |
library => $branch->branchcode, |
1155 |
library => $branch->branchcode, |
|
|
1156 |
exclude_from_local_holds_priority => 0, |
1134 |
} |
1157 |
} |
1135 |
); |
1158 |
); |
1136 |
|
1159 |
|
Lines 1138-1143
subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue
Link Here
|
1138 |
{ |
1161 |
{ |
1139 |
biblionumber => $biblio->biblionumber, |
1162 |
biblionumber => $biblio->biblionumber, |
1140 |
library => $branch->branchcode, |
1163 |
library => $branch->branchcode, |
|
|
1164 |
exclude_from_local_holds_priority => 0, |
1141 |
} |
1165 |
} |
1142 |
); |
1166 |
); |
1143 |
|
1167 |
|
Lines 1169-1174
subtest 'Trivial test for UpdateTransportCostMatrix' => sub {
Link Here
|
1169 |
is( $schema->resultset('TransportCost')->count, 2, 'UpdateTransportCostMatrix added two records' ); |
1193 |
is( $schema->resultset('TransportCost')->count, 2, 'UpdateTransportCostMatrix added two records' ); |
1170 |
}; |
1194 |
}; |
1171 |
|
1195 |
|
|
|
1196 |
subtest 'Excludes from local holds priority' => sub { |
1197 |
plan tests => 5; |
1198 |
|
1199 |
Koha::Holds->delete; |
1200 |
|
1201 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 1 ); |
1202 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityPatronControl', 'PickupLibrary' ); |
1203 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); |
1204 |
|
1205 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
1206 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1207 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} }); |
1208 |
my $excluded_category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 1} }); |
1209 |
my $local_patron_excluded = $builder->build_object( |
1210 |
{ |
1211 |
class => "Koha::Patrons", |
1212 |
value => { |
1213 |
branchcode => $branch->branchcode, |
1214 |
categorycode => $excluded_category->categorycode |
1215 |
} |
1216 |
} |
1217 |
); |
1218 |
|
1219 |
my $local_patron_not_excluded = $builder->build_object( |
1220 |
{ |
1221 |
class => "Koha::Patrons", |
1222 |
value => { |
1223 |
branchcode => $branch->branchcode, |
1224 |
categorycode => $category->categorycode |
1225 |
} |
1226 |
} |
1227 |
); |
1228 |
|
1229 |
my $other_patron = $builder->build_object( |
1230 |
{ |
1231 |
class => "Koha::Patrons", |
1232 |
value => { |
1233 |
branchcode => $branch2->branchcode, |
1234 |
categorycode => $category->categorycode |
1235 |
} |
1236 |
} |
1237 |
); |
1238 |
|
1239 |
my $item1 = $builder->build_sample_item( |
1240 |
{ |
1241 |
library => $branch->branchcode, |
1242 |
exclude_from_local_holds_priority => 0, |
1243 |
} |
1244 |
); |
1245 |
|
1246 |
AddReserve( |
1247 |
{ |
1248 |
branchcode => $other_patron->branchcode, |
1249 |
borrowernumber => $other_patron->borrowernumber, |
1250 |
biblionumber => $item1->biblionumber, |
1251 |
priority => 1 |
1252 |
} |
1253 |
); |
1254 |
|
1255 |
AddReserve( |
1256 |
{ |
1257 |
branchcode => $local_patron_excluded->branchcode, |
1258 |
borrowernumber => $local_patron_excluded->borrowernumber, |
1259 |
biblionumber => $item1->biblionumber, |
1260 |
priority => 2 |
1261 |
} |
1262 |
); |
1263 |
|
1264 |
AddReserve( |
1265 |
{ |
1266 |
branchcode => $local_patron_not_excluded->branchcode, |
1267 |
borrowernumber => $local_patron_not_excluded->borrowernumber, |
1268 |
biblionumber => $item1->biblionumber, |
1269 |
priority => 3 |
1270 |
} |
1271 |
); |
1272 |
|
1273 |
C4::HoldsQueue::CreateQueue(); |
1274 |
|
1275 |
my $queue_rs = $schema->resultset('TmpHoldsqueue'); |
1276 |
my $next = $queue_rs->next; |
1277 |
is($next->borrowernumber, $local_patron_not_excluded->borrowernumber, 'Not excluded local patron is queued'); |
1278 |
|
1279 |
my $item2 = $builder->build_sample_item( |
1280 |
{ |
1281 |
biblionumber => $item1->biblionumber, |
1282 |
library => $branch->branchcode, |
1283 |
exclude_from_local_holds_priority => 1, |
1284 |
} |
1285 |
); |
1286 |
C4::HoldsQueue::CreateQueue(); |
1287 |
|
1288 |
$queue_rs = $schema->resultset('TmpHoldsqueue'); |
1289 |
$next = $queue_rs->next; |
1290 |
is($next->borrowernumber, $local_patron_not_excluded->borrowernumber, 'Not excluded local patron is queued'); |
1291 |
$next = $queue_rs->next; |
1292 |
is($next->borrowernumber, $other_patron->borrowernumber, 'Other patron is queued'); |
1293 |
|
1294 |
$item1->exclude_from_local_holds_priority(1)->store; |
1295 |
|
1296 |
C4::HoldsQueue::CreateQueue(); |
1297 |
|
1298 |
$queue_rs = $schema->resultset('TmpHoldsqueue'); |
1299 |
$next = $queue_rs->next; |
1300 |
is($next->borrowernumber, $other_patron->borrowernumber, 'Other patron is queued'); |
1301 |
$next = $queue_rs->next; |
1302 |
is($next->borrowernumber, $local_patron_excluded->borrowernumber, 'Excluded local patron is queued'); |
1303 |
}; |
1304 |
|
1172 |
# Cleanup |
1305 |
# Cleanup |
1173 |
$schema->storage->txn_rollback; |
1306 |
$schema->storage->txn_rollback; |
1174 |
|
1307 |
|
1175 |
- |
|
|