|
Lines 8-14
Link Here
|
| 8 |
|
8 |
|
| 9 |
use Modern::Perl; |
9 |
use Modern::Perl; |
| 10 |
|
10 |
|
| 11 |
use Test::More tests => 22; |
11 |
use Test::More tests => 23; |
| 12 |
use Data::Dumper; |
12 |
use Data::Dumper; |
| 13 |
|
13 |
|
| 14 |
use C4::Context; |
14 |
use C4::Context; |
|
Lines 53-58
my $itemtype = grep { $_->{notforloan} == 1 } @item_types
Link Here
|
| 53 |
|
53 |
|
| 54 |
#Set up the stage |
54 |
#Set up the stage |
| 55 |
# Sysprefs and cost matrix |
55 |
# Sysprefs and cost matrix |
|
|
56 |
C4::Context->set_preference('HoldsQueueSkipClosed', 0); |
| 56 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
57 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
| 57 |
join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); |
58 |
join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); |
| 58 |
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'"); |
59 |
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'"); |
|
Lines 289-307
ok( @$holds_queue == 2, "Holds queue filling correct number for default holds po
Link Here
|
| 289 |
ok( $holds_queue->[0]->{cardnumber} eq 'CARDNUMBER1', "Holds queue filling 1st correct hold for default holds policy 'from home library'"); |
290 |
ok( $holds_queue->[0]->{cardnumber} eq 'CARDNUMBER1', "Holds queue filling 1st correct hold for default holds policy 'from home library'"); |
| 290 |
ok( $holds_queue->[1]->{cardnumber} eq 'CARDNUMBER2', "Holds queue filling 2nd correct hold for default holds policy 'from home library'"); |
291 |
ok( $holds_queue->[1]->{cardnumber} eq 'CARDNUMBER2', "Holds queue filling 2nd correct hold for default holds policy 'from home library'"); |
| 291 |
|
292 |
|
| 292 |
$dbh->do("DELETE FROM default_circ_rules"); |
|
|
| 293 |
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )"); |
| 294 |
C4::HoldsQueue::CreateQueue(); |
| 295 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
| 296 |
ok( @$holds_queue == 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" ); |
| 297 |
#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue ); |
| 298 |
|
| 299 |
# Test skipping hold picks for closed libraries. |
293 |
# Test skipping hold picks for closed libraries. |
| 300 |
# At this point in the test, we have 3 rows in the holds queue |
294 |
# At this point in the test, we have 2 rows in the holds queue |
| 301 |
# one of which is coming from MPL. Let's enable HoldsQueueSkipClosed |
295 |
# 1 of which is coming from MPL. Let's enable HoldsQueueSkipClosed |
| 302 |
# and make today a holiday for MPL. When we run it again we should only |
296 |
# and make today a holiday for MPL. When we run it again we should only |
| 303 |
# have 2 rows in the holds queue |
297 |
# have 1 row in the holds queue |
| 304 |
C4::Context->set_preference( 'HoldsQueueSkipClosed', 1 ); |
298 |
C4::Context->set_preference('HoldsQueueSkipClosed', 1); |
| 305 |
my $today = dt_from_string(); |
299 |
my $today = dt_from_string(); |
| 306 |
C4::Calendar->new( branchcode => 'MPL' )->insert_single_holiday( |
300 |
C4::Calendar->new( branchcode => 'MPL' )->insert_single_holiday( |
| 307 |
day => $today->day(), |
301 |
day => $today->day(), |
|
Lines 312-317
C4::Calendar->new( branchcode => 'MPL' )->insert_single_holiday(
Link Here
|
| 312 |
); |
306 |
); |
| 313 |
C4::HoldsQueue::CreateQueue(); |
307 |
C4::HoldsQueue::CreateQueue(); |
| 314 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
308 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
|
|
309 |
ok( @$holds_queue == 1, "Holds not filled with items from closed libraries" ); |
| 310 |
C4::Context->set_preference('HoldsQueueSkipClosed', 0); |
| 311 |
|
| 312 |
$dbh->do("DELETE FROM default_circ_rules"); |
| 313 |
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )"); |
| 314 |
C4::HoldsQueue::CreateQueue(); |
| 315 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
| 316 |
ok( @$holds_queue == 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" ); |
| 317 |
#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue ); |
| 318 |
|
| 319 |
# Test skipping hold picks for closed libraries without transport cost matrix |
| 320 |
# At this point in the test, we have 3 rows in the holds queue |
| 321 |
# one of which is coming from MPL. Let's enable HoldsQueueSkipClosed |
| 322 |
# and use our previously created holiday for MPL. |
| 323 |
# When we run it again we should only have 2 rows in the holds queue |
| 324 |
C4::Context->set_preference( 'HoldsQueueSkipClosed', 1 ); |
| 325 |
C4::HoldsQueue::CreateQueue(); |
| 326 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
| 315 |
ok( @$holds_queue == 2, "Holds not filled with items from closed libraries" ); |
327 |
ok( @$holds_queue == 2, "Holds not filled with items from closed libraries" ); |
| 316 |
|
328 |
|
| 317 |
# Cleanup |
329 |
# Cleanup |
| 318 |
- |
|
|