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