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