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