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