Lines 12-18
use C4::Context;
Link Here
|
12 |
|
12 |
|
13 |
use Data::Dumper; |
13 |
use Data::Dumper; |
14 |
|
14 |
|
15 |
use Test::More tests => 23; |
15 |
use Test::More tests => 27; |
16 |
|
16 |
|
17 |
use C4::Branch; |
17 |
use C4::Branch; |
18 |
use C4::Members; |
18 |
use C4::Members; |
Lines 66-71
$itemtype or BAIL_OUT("No adequate itemtype"); #FIXME Should be $itemtype = $ite
Link Here
|
66 |
|
66 |
|
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('LocalHoldsPriority', 0); |
69 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
70 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
70 |
join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); |
71 |
join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); |
71 |
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'"); |
72 |
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'"); |
Lines 307-312
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice
Link Here
|
307 |
is( @$holds_queue, 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" ); |
308 |
is( @$holds_queue, 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" ); |
308 |
#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue ); |
309 |
#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue ); |
309 |
|
310 |
|
|
|
311 |
## Test LocalHoldsPriority |
312 |
C4::Context->set_preference('LocalHoldsPriority', 1); |
313 |
|
314 |
$dbh->do("DELETE FROM default_circ_rules"); |
315 |
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )"); |
316 |
$dbh->do("DELETE FROM issues"); |
317 |
|
318 |
# Test homebranch = patron branch |
319 |
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary'); |
320 |
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'homebranch'); |
321 |
C4::Context->clear_syspref_cache(); |
322 |
$dbh->do("DELETE FROM reserves"); |
323 |
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); |
324 |
$sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[0], 2 ); |
325 |
$sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ); |
326 |
|
327 |
$dbh->do("DELETE FROM items"); |
328 |
# barcode, homebranch, holdingbranch, itemtype |
329 |
$items_insert_sth->execute( $barcode + 4, $branchcodes[2], $branchcodes[0] ); |
330 |
|
331 |
C4::HoldsQueue::CreateQueue(); |
332 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
333 |
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's home library"); |
334 |
|
335 |
# Test holdingbranch = patron branch |
336 |
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary'); |
337 |
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'holdingbranch'); |
338 |
C4::Context->clear_syspref_cache(); |
339 |
$dbh->do("DELETE FROM reserves"); |
340 |
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); |
341 |
$sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[0], 2 ); |
342 |
$sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ); |
343 |
|
344 |
$dbh->do("DELETE FROM items"); |
345 |
# barcode, homebranch, holdingbranch, itemtype |
346 |
$items_insert_sth->execute( $barcode + 4, $branchcodes[0], $branchcodes[2] ); |
347 |
|
348 |
C4::HoldsQueue::CreateQueue(); |
349 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
350 |
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's holding library"); |
351 |
|
352 |
# Test holdingbranch = pickup branch |
353 |
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary'); |
354 |
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'holdingbranch'); |
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[2], 3 ); |
360 |
|
361 |
$dbh->do("DELETE FROM items"); |
362 |
# barcode, homebranch, holdingbranch, itemtype |
363 |
$items_insert_sth->execute( $barcode + 4, $branchcodes[0], $branchcodes[2] ); |
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 holding library"); |
368 |
|
369 |
# Test homebranch = pickup branch |
370 |
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary'); |
371 |
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'homebranch'); |
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[2], 3 ); |
377 |
|
378 |
$dbh->do("DELETE FROM items"); |
379 |
# barcode, homebranch, holdingbranch, itemtype |
380 |
$items_insert_sth->execute( $barcode + 4, $branchcodes[2], $branchcodes[0] ); |
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 |
C4::Context->set_preference('LocalHoldsPriority', 0); |
387 |
## End testing of LocalHoldsPriority |
388 |
|
389 |
|
310 |
# Bug 14297 |
390 |
# Bug 14297 |
311 |
$itemtype = Koha::ItemTypes->search->next->itemtype; |
391 |
$itemtype = Koha::ItemTypes->search->next->itemtype; |
312 |
$borrowernumber = $borrower3->{borrowernumber}; |
392 |
$borrowernumber = $borrower3->{borrowernumber}; |
313 |
- |
|
|