Lines 8-14
Link Here
|
8 |
|
8 |
|
9 |
use Modern::Perl; |
9 |
use Modern::Perl; |
10 |
|
10 |
|
11 |
use Test::More tests => 38; |
11 |
use Test::More tests => 42; |
12 |
use Data::Dumper; |
12 |
use Data::Dumper; |
13 |
|
13 |
|
14 |
use C4::Branch; |
14 |
use C4::Branch; |
Lines 63-68
my $itemtype = $builder->build({ source => 'Itemtype', value => { notforloan =>
Link Here
|
63 |
#Set up the stage |
63 |
#Set up the stage |
64 |
# Sysprefs and cost matrix |
64 |
# Sysprefs and cost matrix |
65 |
C4::Context->set_preference('HoldsQueueSkipClosed', 0); |
65 |
C4::Context->set_preference('HoldsQueueSkipClosed', 0); |
|
|
66 |
C4::Context->set_preference('LocalHoldsPriority', 0); |
66 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
67 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
67 |
join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); |
68 |
join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); |
68 |
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'"); |
69 |
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'"); |
Lines 333-338
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice
Link Here
|
333 |
is( scalar( @$holds_queue ), 2, "Holds not filled with items from closed libraries" ); |
334 |
is( scalar( @$holds_queue ), 2, "Holds not filled with items from closed libraries" ); |
334 |
C4::Context->set_preference( 'HoldsQueueSkipClosed', 0 ); |
335 |
C4::Context->set_preference( 'HoldsQueueSkipClosed', 0 ); |
335 |
|
336 |
|
|
|
337 |
## Test LocalHoldsPriority |
338 |
C4::Context->set_preference('LocalHoldsPriority', 1); |
339 |
|
340 |
$dbh->do("DELETE FROM default_circ_rules"); |
341 |
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )"); |
342 |
$dbh->do("DELETE FROM issues"); |
343 |
|
344 |
# Test homebranch = patron branch |
345 |
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary'); |
346 |
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'homebranch'); |
347 |
C4::Context->clear_syspref_cache(); |
348 |
$dbh->do("DELETE FROM reserves"); |
349 |
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); |
350 |
$sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[0], 2 ); |
351 |
$sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ); |
352 |
|
353 |
$dbh->do("DELETE FROM items"); |
354 |
# barcode, homebranch, holdingbranch, itemtype |
355 |
$items_insert_sth->execute( $barcode + 4, $branchcodes[2], $branchcodes[0] ); |
356 |
|
357 |
C4::HoldsQueue::CreateQueue(); |
358 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
359 |
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's home library"); |
360 |
|
361 |
# Test holdingbranch = patron branch |
362 |
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary'); |
363 |
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'holdingbranch'); |
364 |
C4::Context->clear_syspref_cache(); |
365 |
$dbh->do("DELETE FROM reserves"); |
366 |
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); |
367 |
$sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[0], 2 ); |
368 |
$sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ); |
369 |
|
370 |
$dbh->do("DELETE FROM items"); |
371 |
# barcode, homebranch, holdingbranch, itemtype |
372 |
$items_insert_sth->execute( $barcode + 4, $branchcodes[0], $branchcodes[2] ); |
373 |
|
374 |
C4::HoldsQueue::CreateQueue(); |
375 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
376 |
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's holding library"); |
377 |
|
378 |
# Test holdingbranch = pickup branch |
379 |
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary'); |
380 |
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'holdingbranch'); |
381 |
C4::Context->clear_syspref_cache(); |
382 |
$dbh->do("DELETE FROM reserves"); |
383 |
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); |
384 |
$sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[0], 2 ); |
385 |
$sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[2], 3 ); |
386 |
|
387 |
$dbh->do("DELETE FROM items"); |
388 |
# barcode, homebranch, holdingbranch, itemtype |
389 |
$items_insert_sth->execute( $barcode + 4, $branchcodes[0], $branchcodes[2] ); |
390 |
|
391 |
C4::HoldsQueue::CreateQueue(); |
392 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
393 |
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's holding library"); |
394 |
|
395 |
# Test homebranch = pickup branch |
396 |
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary'); |
397 |
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'homebranch'); |
398 |
C4::Context->clear_syspref_cache(); |
399 |
$dbh->do("DELETE FROM reserves"); |
400 |
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); |
401 |
$sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[0], 2 ); |
402 |
$sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[2], 3 ); |
403 |
|
404 |
$dbh->do("DELETE FROM items"); |
405 |
# barcode, homebranch, holdingbranch, itemtype |
406 |
$items_insert_sth->execute( $barcode + 4, $branchcodes[2], $branchcodes[0] ); |
407 |
|
408 |
C4::HoldsQueue::CreateQueue(); |
409 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
410 |
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's holding library"); |
411 |
|
412 |
C4::Context->set_preference('LocalHoldsPriority', 0); |
413 |
## End testing of LocalHoldsPriority |
414 |
|
415 |
|
336 |
# Bug 14297 |
416 |
# Bug 14297 |
337 |
$itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } })->{itemtype}; |
417 |
$itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } })->{itemtype}; |
338 |
$borrowernumber = $borrower3->{borrowernumber}; |
418 |
$borrowernumber = $borrower3->{borrowernumber}; |
339 |
- |
|
|