|
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; |
| 20 |
use Koha::Cache; |
| 21 |
|
21 |
|
| 22 |
BEGIN { |
22 |
BEGIN { |
| 23 |
use FindBin; |
23 |
use FindBin; |
|
Lines 55-60
my $itemtype = grep { $_->{notforloan} == 1 } @item_types
Link Here
|
| 55 |
|
55 |
|
| 56 |
#Set up the stage |
56 |
#Set up the stage |
| 57 |
# Sysprefs and cost matrix |
57 |
# Sysprefs and cost matrix |
|
|
58 |
C4::Context->set_preference('HoldsQueueSkipClosed', 0); |
| 58 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
59 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
| 59 |
join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); |
60 |
join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); |
| 60 |
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'"); |
61 |
$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'"); |
291 |
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'"); |
292 |
ok( $holds_queue->[1]->{cardnumber} eq 'CARDNUMBER2', "Holds queue filling 2nd correct hold for default holds policy 'from home library'"); |
| 292 |
|
293 |
|
|
|
294 |
# Test skipping hold picks for closed libraries. |
| 295 |
# At this point in the test, we have 2 rows in the holds queue |
| 296 |
# 1 of which is coming from MPL. Let's enable HoldsQueueSkipClosed |
| 297 |
# and make today a holiday for MPL. When we run it again we should only |
| 298 |
# have 1 row in the holds queue |
| 299 |
C4::Context->set_preference('HoldsQueueSkipClosed', 1); |
| 300 |
my $today = dt_from_string(); |
| 301 |
C4::Calendar->new( branchcode => 'MPL' )->insert_single_holiday( |
| 302 |
day => $today->day(), |
| 303 |
month => $today->month(), |
| 304 |
year => $today->year(), |
| 305 |
title => "$today", |
| 306 |
description => "$today", |
| 307 |
); |
| 308 |
C4::HoldsQueue::CreateQueue(); |
| 309 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
| 310 |
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" ); |
| 311 |
C4::Context->set_preference('HoldsQueueSkipClosed', 0); |
| 312 |
|
| 293 |
$dbh->do("DELETE FROM default_circ_rules"); |
313 |
$dbh->do("DELETE FROM default_circ_rules"); |
| 294 |
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )"); |
314 |
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )"); |
| 295 |
C4::HoldsQueue::CreateQueue(); |
315 |
C4::HoldsQueue::CreateQueue(); |
| 296 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
316 |
$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'" ); |
317 |
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 ); |
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 => {} }); |
| 327 |
is( scalar( @$holds_queue ), 2, "Holds not filled with items from closed libraries" ); |
| 299 |
|
328 |
|
| 300 |
# Bug 14297 |
329 |
# Bug 14297 |
| 301 |
$borrowernumber = AddMember(%data); |
330 |
$borrowernumber = AddMember(%data); |
| 302 |
- |
|
|