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 => 23; |
|
|
16 |
|
17 |
use C4::Branch; |
14 |
use C4::Branch; |
18 |
use C4::Members; |
15 |
use C4::Members; |
19 |
use Koha::Database; |
16 |
use Koha::Database; |
20 |
|
17 |
|
|
|
18 |
use C4::Calendar; |
19 |
use C4::Context; |
20 |
use C4::Branch; |
21 |
use C4::ItemType; |
22 |
use C4::Members; |
23 |
use Koha::DateUtils; |
24 |
|
21 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
22 |
|
26 |
|
23 |
use Koha::ItemTypes; |
27 |
use Koha::ItemTypes; |
Lines 66-71
$itemtype or BAIL_OUT("No adequate itemtype"); #FIXME Should be $itemtype = $ite
Link Here
|
66 |
|
70 |
|
67 |
#Set up the stage |
71 |
#Set up the stage |
68 |
# Sysprefs and cost matrix |
72 |
# Sysprefs and cost matrix |
|
|
73 |
C4::Context->set_preference('HoldsQueueSkipClosed', 0); |
69 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
74 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
70 |
join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); |
75 |
join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code)); |
71 |
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'"); |
76 |
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'"); |
Lines 300-311
is( @$holds_queue, 2, "Holds queue filling correct number for default holds poli
Link Here
|
300 |
is( $holds_queue->[0]->{cardnumber}, $borrower1->{cardnumber}, "Holds queue filling 1st correct hold for default holds policy 'from home library'"); |
305 |
is( $holds_queue->[0]->{cardnumber}, $borrower1->{cardnumber}, "Holds queue filling 1st correct hold for default holds policy 'from home library'"); |
301 |
is( $holds_queue->[1]->{cardnumber}, $borrower2->{cardnumber}, "Holds queue filling 2nd correct hold for default holds policy 'from home library'"); |
306 |
is( $holds_queue->[1]->{cardnumber}, $borrower2->{cardnumber}, "Holds queue filling 2nd correct hold for default holds policy 'from home library'"); |
302 |
|
307 |
|
|
|
308 |
# Test skipping hold picks for closed libraries. |
309 |
# At this point in the test, we have 2 rows in the holds queue |
310 |
# 1 of which is coming from MPL. Let's enable HoldsQueueSkipClosed |
311 |
# and make today a holiday for MPL. When we run it again we should only |
312 |
# have 1 row in the holds queue |
313 |
C4::Context->set_preference('HoldsQueueSkipClosed', 1); |
314 |
my $today = dt_from_string(); |
315 |
C4::Calendar->new( branchcode => 'MPL' )->insert_single_holiday( |
316 |
day => $today->day(), |
317 |
month => $today->month(), |
318 |
year => $today->year(), |
319 |
title => "$today", |
320 |
description => "$today", |
321 |
); |
322 |
C4::HoldsQueue::CreateQueue(); |
323 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
324 |
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" ); |
325 |
C4::Context->set_preference('HoldsQueueSkipClosed', 0); |
326 |
|
303 |
$dbh->do("DELETE FROM default_circ_rules"); |
327 |
$dbh->do("DELETE FROM default_circ_rules"); |
304 |
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )"); |
328 |
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )"); |
305 |
C4::HoldsQueue::CreateQueue(); |
329 |
C4::HoldsQueue::CreateQueue(); |
306 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
330 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
307 |
is( @$holds_queue, 3, "Holds queue filling correct number for holds for default holds policy 'from any library'" ); |
331 |
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 ); |
332 |
|
|
|
333 |
# Test skipping hold picks for closed libraries without transport cost matrix |
334 |
# At this point in the test, we have 3 rows in the holds queue |
335 |
# one of which is coming from MPL. Let's enable HoldsQueueSkipClosed |
336 |
# and use our previously created holiday for MPL. |
337 |
# When we run it again we should only have 2 rows in the holds queue |
338 |
C4::Context->set_preference( 'HoldsQueueSkipClosed', 1 ); |
339 |
C4::HoldsQueue::CreateQueue(); |
340 |
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} }); |
341 |
is( scalar( @$holds_queue ), 2, "Holds not filled with items from closed libraries" ); |
309 |
|
342 |
|
310 |
# Bug 14297 |
343 |
# Bug 14297 |
311 |
$itemtype = Koha::ItemTypes->search->next->itemtype; |
344 |
$itemtype = Koha::ItemTypes->search->next->itemtype; |
312 |
- |
|
|