View | Details | Raw Unified | Return to bug 17633
Collapse All | Expand All

(-)a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t (-1 / +2 lines)
Lines 20-25 use Modern::Perl; Link Here
20
use Test::More tests => 2;
20
use Test::More tests => 2;
21
21
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
use t::lib::Mocks;
23
24
24
use C4::Accounts qw( manualinvoice );
25
use C4::Accounts qw( manualinvoice );
25
use C4::Circulation qw( CanBookBeIssued );
26
use C4::Circulation qw( CanBookBeIssued );
Lines 53-59 my $guarantee = $builder->build( Link Here
53
    }
54
    }
54
);
55
);
55
56
56
C4::Context->set_preference( 'NoIssuesChargeGuarantees', '5.00' );
57
t::lib::Mocks::mock_preference( 'NoIssuesChargeGuarantees', '5.00' );
57
58
58
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
59
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
59
is( $issuingimpossible->{DEBT_GUARANTEES}, undef, "Patron can check out item" );
60
is( $issuingimpossible->{DEBT_GUARANTEES}, undef, "Patron can check out item" );
(-)a/t/db_dependent/Circulation/Returns.t (-8 / +8 lines)
Lines 70-76 subtest "InProcessingToShelvingCart tests" => sub { Link Here
70
    my $itemnumber = $built_item->{ itemnumber };
70
    my $itemnumber = $built_item->{ itemnumber };
71
    my $item;
71
    my $item;
72
72
73
    C4::Context->set_preference( "InProcessingToShelvingCart", 1 );
73
    t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 1 );
74
    AddReturn( $barcode, $branch );
74
    AddReturn( $barcode, $branch );
75
    $item = GetItem( $itemnumber );
75
    $item = GetItem( $itemnumber );
76
    is( $item->{location}, 'CART',
76
    is( $item->{location}, 'CART',
Lines 79-85 subtest "InProcessingToShelvingCart tests" => sub { Link Here
79
    $item->{location} = $location;
79
    $item->{location} = $location;
80
    ModItem( $item, undef, $itemnumber );
80
    ModItem( $item, undef, $itemnumber );
81
81
82
    C4::Context->set_preference( "InProcessingToShelvingCart", 0 );
82
    t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 0 );
83
    AddReturn( $barcode, $branch );
83
    AddReturn( $barcode, $branch );
84
    $item = GetItem( $itemnumber );
84
    $item = GetItem( $itemnumber );
85
    is( $item->{location}, $permanent_location,
85
    is( $item->{location}, $permanent_location,
Lines 92-102 subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub { Link Here
92
    plan tests => 2;
92
    plan tests => 2;
93
93
94
    # Set item-level item types
94
    # Set item-level item types
95
    C4::Context->set_preference( "item-level_itypes", 1 );
95
    t::lib::Mocks::mock_preference( "item-level_itypes", 1 );
96
96
97
    # Make sure logging is enabled
97
    # Make sure logging is enabled
98
    C4::Context->set_preference( "IssueLog", 1 );
98
    t::lib::Mocks::mock_preference( "IssueLog", 1 );
99
    C4::Context->set_preference( "ReturnLog", 1 );
99
    t::lib::Mocks::mock_preference( "ReturnLog", 1 );
100
100
101
    # Create an itemtype for biblio-level item type
101
    # Create an itemtype for biblio-level item type
102
    my $blevel_itemtype = $builder->build({ source => 'Itemtype' })->{ itemtype };
102
    my $blevel_itemtype = $builder->build({ source => 'Itemtype' })->{ itemtype };
Lines 180-190 subtest "AddReturn logging on statistics table (item-level_itypes=0)" => sub { Link Here
180
    plan tests => 2;
180
    plan tests => 2;
181
181
182
    # Make sure logging is enabled
182
    # Make sure logging is enabled
183
    C4::Context->set_preference( "IssueLog", 1 );
183
    t::lib::Mocks::mock_preference( "IssueLog", 1 );
184
    C4::Context->set_preference( "ReturnLog", 1 );
184
    t::lib::Mocks::mock_preference( "ReturnLog", 1 );
185
185
186
    # Set item-level item types
186
    # Set item-level item types
187
    C4::Context->set_preference( "item-level_itypes", 0 );
187
    t::lib::Mocks::mock_preference( "item-level_itypes", 0 );
188
188
189
    # Create an itemtype for biblio-level item type
189
    # Create an itemtype for biblio-level item type
190
    my $blevel_itemtype = $builder->build({ source => 'Itemtype' })->{ itemtype };
190
    my $blevel_itemtype = $builder->build({ source => 'Itemtype' })->{ itemtype };
(-)a/t/db_dependent/DecreaseLoanHighHolds.t (-8 / +9 lines)
Lines 25-30 use Koha::Item; Link Here
25
use Koha::Holds;
25
use Koha::Holds;
26
use Koha::Hold;
26
use Koha::Hold;
27
use t::lib::TestBuilder;
27
use t::lib::TestBuilder;
28
use t::lib::Mocks;
28
29
29
use Test::More tests => 14;
30
use Test::More tests => 14;
30
31
Lines 103-113 $builder->build( Link Here
103
my $item   = pop(@items);
104
my $item   = pop(@items);
104
my $patron = pop(@patrons);
105
my $patron = pop(@patrons);
105
106
106
C4::Context->set_preference( 'decreaseLoanHighHolds',               1 );
107
t::lib::Mocks::mock_preference( 'decreaseLoanHighHolds',               1 );
107
C4::Context->set_preference( 'decreaseLoanHighHoldsDuration',       1 );
108
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsDuration',       1 );
108
C4::Context->set_preference( 'decreaseLoanHighHoldsValue',          1 );
109
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsValue',          1 );
109
C4::Context->set_preference( 'decreaseLoanHighHoldsControl',        'static' );
110
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl',        'static' );
110
C4::Context->set_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
111
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
111
112
112
my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, barcode => $item->barcode };
113
my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, barcode => $item->barcode };
113
my $patron_hr = { borrowernumber => $patron->id, branchcode => $library->{branchcode} };
114
my $patron_hr = { borrowernumber => $patron->id, branchcode => $library->{branchcode} };
Lines 118-124 is( $data->{outstanding}, 6, "Should have 5 outstanding holds" ); Link Here
118
is( $data->{duration},        1,          "Should have duration of 1" );
119
is( $data->{duration},        1,          "Should have duration of 1" );
119
is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" );
120
is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" );
120
121
121
C4::Context->set_preference( 'decreaseLoanHighHoldsControl', 'dynamic' );
122
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl', 'dynamic' );
122
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
123
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
123
is( $data->{exceeded}, 0, "Should not exceed threshold" );
124
is( $data->{exceeded}, 0, "Should not exceed threshold" );
124
125
Lines 136-142 for my $i ( 5 .. 10 ) { Link Here
136
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
137
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
137
is( $data->{exceeded}, 1, "Should exceed threshold of 1" );
138
is( $data->{exceeded}, 1, "Should exceed threshold of 1" );
138
139
139
C4::Context->set_preference( 'decreaseLoanHighHoldsValue', 2 );
140
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsValue', 2 );
140
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
141
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
141
is( $data->{exceeded}, 0, "Should not exceed threshold of 2" );
142
is( $data->{exceeded}, 0, "Should not exceed threshold of 2" );
142
143
Lines 168-174 $unholdable->store(); Link Here
168
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
169
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
169
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
170
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
170
171
171
C4::Context->set_preference('CircControl', 'PatronLibrary');
172
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary');
172
173
173
my ( undef, $needsconfirmation ) = CanBookBeIssued( $patron_hr, $item->barcode );
174
my ( undef, $needsconfirmation ) = CanBookBeIssued( $patron_hr, $item->barcode );
174
ok( $needsconfirmation->{HIGHHOLDS}, "High holds checkout needs confirmation" );
175
ok( $needsconfirmation->{HIGHHOLDS}, "High holds checkout needs confirmation" );
(-)a/t/db_dependent/HoldsQueue.t (-23 / +24 lines)
Lines 18-23 use Koha::Database; Link Here
18
use Koha::DateUtils;
18
use Koha::DateUtils;
19
19
20
use t::lib::TestBuilder;
20
use t::lib::TestBuilder;
21
use t::lib::Mocks;
21
22
22
BEGIN {
23
BEGIN {
23
    use FindBin;
24
    use FindBin;
Lines 61-68 my $itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => Link Here
61
62
62
#Set up the stage
63
#Set up the stage
63
# Sysprefs and cost matrix
64
# Sysprefs and cost matrix
64
C4::Context->set_preference('HoldsQueueSkipClosed', 0);
65
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
65
C4::Context->set_preference('LocalHoldsPriority', 0);
66
t::lib::Mocks::mock_preference('LocalHoldsPriority', 0);
66
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef,
67
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef,
67
         join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code));
68
         join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code));
68
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'");
69
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'");
Lines 118-124 my $test_sth = $dbh->prepare("SELECT * FROM hold_fill_targets Link Here
118
                              WHERE borrowernumber = $borrowernumber");
119
                              WHERE borrowernumber = $borrowernumber");
119
120
120
# We have a book available homed in borrower branch, no point fiddling with AutomaticItemReturn
121
# We have a book available homed in borrower branch, no point fiddling with AutomaticItemReturn
121
C4::Context->set_preference('AutomaticItemReturn', 0);
122
t::lib::Mocks::mock_preference('AutomaticItemReturn', 0);
122
test_queue ('take from homebranch',  0, $borrower_branchcode, $borrower_branchcode);
123
test_queue ('take from homebranch',  0, $borrower_branchcode, $borrower_branchcode);
123
test_queue ('take from homebranch',  1, $borrower_branchcode, $borrower_branchcode);
124
test_queue ('take from homebranch',  1, $borrower_branchcode, $borrower_branchcode);
124
125
Lines 127-140 $dbh->do("DELETE FROM hold_fill_targets"); Link Here
127
$dbh->do("DELETE FROM issues WHERE itemnumber IN (SELECT itemnumber FROM items WHERE homebranch = '$borrower_branchcode' AND holdingbranch = '$borrower_branchcode')");
128
$dbh->do("DELETE FROM issues WHERE itemnumber IN (SELECT itemnumber FROM items WHERE homebranch = '$borrower_branchcode' AND holdingbranch = '$borrower_branchcode')");
128
$dbh->do("DELETE FROM items WHERE homebranch = '$borrower_branchcode' AND holdingbranch = '$borrower_branchcode'");
129
$dbh->do("DELETE FROM items WHERE homebranch = '$borrower_branchcode' AND holdingbranch = '$borrower_branchcode'");
129
# test_queue will flush
130
# test_queue will flush
130
C4::Context->set_preference('AutomaticItemReturn', 1);
131
t::lib::Mocks::mock_preference('AutomaticItemReturn', 1);
131
# Not sure how to make this test more difficult - holding branch does not matter
132
# Not sure how to make this test more difficult - holding branch does not matter
132
133
133
$dbh->do("DELETE FROM tmp_holdsqueue");
134
$dbh->do("DELETE FROM tmp_holdsqueue");
134
$dbh->do("DELETE FROM hold_fill_targets");
135
$dbh->do("DELETE FROM hold_fill_targets");
135
$dbh->do("DELETE FROM issues WHERE itemnumber IN (SELECT itemnumber FROM items WHERE homebranch = '$borrower_branchcode')");
136
$dbh->do("DELETE FROM issues WHERE itemnumber IN (SELECT itemnumber FROM items WHERE homebranch = '$borrower_branchcode')");
136
$dbh->do("DELETE FROM items WHERE homebranch = '$borrower_branchcode'");
137
$dbh->do("DELETE FROM items WHERE homebranch = '$borrower_branchcode'");
137
C4::Context->set_preference('AutomaticItemReturn', 0);
138
t::lib::Mocks::mock_preference('AutomaticItemReturn', 0);
138
# We have a book available held in borrower branch
139
# We have a book available held in borrower branch
139
test_queue ('take from holdingbranch', 0, $borrower_branchcode, $borrower_branchcode);
140
test_queue ('take from holdingbranch', 0, $borrower_branchcode, $borrower_branchcode);
140
test_queue ('take from holdingbranch', 1, $borrower_branchcode, $borrower_branchcode);
141
test_queue ('take from holdingbranch', 1, $borrower_branchcode, $borrower_branchcode);
Lines 173-179 $dbh->do("DELETE FROM default_branch_circ_rules"); Link Here
173
$dbh->do("DELETE FROM default_branch_item_rules");
174
$dbh->do("DELETE FROM default_branch_item_rules");
174
$dbh->do("DELETE FROM default_circ_rules");
175
$dbh->do("DELETE FROM default_circ_rules");
175
176
176
C4::Context->set_preference('UseTransportCostMatrix', 0);
177
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0);
177
178
178
$itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } })->{itemtype};
179
$itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } })->{itemtype};
179
180
Lines 299-305 is( $holds_queue->[1]->{cardnumber}, $borrower2->{cardnumber}, "Holds queue fill Link Here
299
# 1 of which is coming from MPL. Let's enable HoldsQueueSkipClosed
300
# 1 of which is coming from MPL. Let's enable HoldsQueueSkipClosed
300
# and make today a holiday for MPL. When we run it again we should only
301
# and make today a holiday for MPL. When we run it again we should only
301
# have 1 row in the holds queue
302
# have 1 row in the holds queue
302
C4::Context->set_preference('HoldsQueueSkipClosed', 1);
303
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 1);
303
my $today = dt_from_string();
304
my $today = dt_from_string();
304
C4::Calendar->new( branchcode => $branchcodes[0] )->insert_single_holiday(
305
C4::Calendar->new( branchcode => $branchcodes[0] )->insert_single_holiday(
305
    day         => $today->day(),
306
    day         => $today->day(),
Lines 314-320 is( Koha::Calendar->new( branchcode => $branchcodes[0] )->is_holiday( $today ), Link Here
314
C4::HoldsQueue::CreateQueue();
315
C4::HoldsQueue::CreateQueue();
315
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
316
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
316
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
317
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
317
C4::Context->set_preference('HoldsQueueSkipClosed', 0);
318
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
318
319
319
$dbh->do("DELETE FROM default_circ_rules");
320
$dbh->do("DELETE FROM default_circ_rules");
320
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
321
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
Lines 327-348 is( @$holds_queue, 3, "Holds queue filling correct number for holds for default Link Here
327
# one of which is coming from MPL. Let's enable HoldsQueueSkipClosed
328
# one of which is coming from MPL. Let's enable HoldsQueueSkipClosed
328
# and use our previously created holiday for MPL
329
# and use our previously created holiday for MPL
329
# When we run it again we should only have 2 rows in the holds queue
330
# When we run it again we should only have 2 rows in the holds queue
330
C4::Context->set_preference( 'HoldsQueueSkipClosed', 1 );
331
t::lib::Mocks::mock_preference( 'HoldsQueueSkipClosed', 1 );
331
C4::HoldsQueue::CreateQueue();
332
C4::HoldsQueue::CreateQueue();
332
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
333
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
333
is( scalar( @$holds_queue ), 2, "Holds not filled with items from closed libraries" );
334
is( scalar( @$holds_queue ), 2, "Holds not filled with items from closed libraries" );
334
C4::Context->set_preference( 'HoldsQueueSkipClosed', 0 );
335
t::lib::Mocks::mock_preference( 'HoldsQueueSkipClosed', 0 );
335
336
336
## Test LocalHoldsPriority
337
## Test LocalHoldsPriority
337
C4::Context->set_preference('LocalHoldsPriority', 1);
338
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1);
338
339
339
$dbh->do("DELETE FROM default_circ_rules");
340
$dbh->do("DELETE FROM default_circ_rules");
340
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
341
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
341
$dbh->do("DELETE FROM issues");
342
$dbh->do("DELETE FROM issues");
342
343
343
# Test homebranch = patron branch
344
# Test homebranch = patron branch
344
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary');
345
t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary');
345
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'homebranch');
346
t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'homebranch');
346
C4::Context->clear_syspref_cache();
347
C4::Context->clear_syspref_cache();
347
$dbh->do("DELETE FROM reserves");
348
$dbh->do("DELETE FROM reserves");
348
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 );
349
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 );
Lines 358-365 $holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice Link Here
358
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's home library");
359
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's home library");
359
360
360
# Test holdingbranch = patron branch
361
# Test holdingbranch = patron branch
361
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary');
362
t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary');
362
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'holdingbranch');
363
t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'holdingbranch');
363
C4::Context->clear_syspref_cache();
364
C4::Context->clear_syspref_cache();
364
$dbh->do("DELETE FROM reserves");
365
$dbh->do("DELETE FROM reserves");
365
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 );
366
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 );
Lines 375-382 $holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice Link Here
375
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's holding library");
376
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's holding library");
376
377
377
# Test holdingbranch = pickup branch
378
# Test holdingbranch = pickup branch
378
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary');
379
t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary');
379
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'holdingbranch');
380
t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'holdingbranch');
380
C4::Context->clear_syspref_cache();
381
C4::Context->clear_syspref_cache();
381
$dbh->do("DELETE FROM reserves");
382
$dbh->do("DELETE FROM reserves");
382
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 );
383
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 );
Lines 392-399 $holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice Link Here
392
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's holding library");
393
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's holding library");
393
394
394
# Test homebranch = pickup branch
395
# Test homebranch = pickup branch
395
C4::Context->set_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary');
396
t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary');
396
C4::Context->set_preference('LocalHoldsPriorityItemControl', 'homebranch');
397
t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'homebranch');
397
C4::Context->clear_syspref_cache();
398
C4::Context->clear_syspref_cache();
398
$dbh->do("DELETE FROM reserves");
399
$dbh->do("DELETE FROM reserves");
399
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 );
400
$sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 );
Lines 408-414 C4::HoldsQueue::CreateQueue(); Link Here
408
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
409
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
409
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's holding library");
410
is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue giving priority to patron who's home library matches item's holding library");
410
411
411
C4::Context->set_preference('LocalHoldsPriority', 0);
412
t::lib::Mocks::mock_preference('LocalHoldsPriority', 0);
412
## End testing of LocalHoldsPriority
413
## End testing of LocalHoldsPriority
413
414
414
415
Lines 487-493 $dbh->do("DELETE FROM default_branch_item_rules"); Link Here
487
$dbh->do("DELETE FROM default_circ_rules");
488
$dbh->do("DELETE FROM default_circ_rules");
488
$dbh->do("DELETE FROM branch_item_rules");
489
$dbh->do("DELETE FROM branch_item_rules");
489
490
490
C4::Context->set_preference("UseTransportCostMatrix",1);
491
t::lib::Mocks::mock_preference("UseTransportCostMatrix",1);
491
492
492
my $tc_rs = $schema->resultset('TransportCost');
493
my $tc_rs = $schema->resultset('TransportCost');
493
$tc_rs->create({ frombranch => $library_A, tobranch => $library_B, cost => 0, disable_transfer => 1 });
494
$tc_rs->create({ frombranch => $library_A, tobranch => $library_B, cost => 0, disable_transfer => 1 });
Lines 518-524 is( @$holds_queue, 0, "Bug 15062 - Holds queue with Transport Cost Matrix will t Link Here
518
# End Bug 15062
519
# End Bug 15062
519
520
520
# Test hold_fulfillment_policy
521
# Test hold_fulfillment_policy
521
C4::Context->set_preference( "UseTransportCostMatrix", 0 );
522
t::lib::Mocks::mock_preference( "UseTransportCostMatrix", 0 );
522
$borrowernumber = $borrower3->{borrowernumber};
523
$borrowernumber = $borrower3->{borrowernumber};
523
$library_A = $library1->{branchcode};
524
$library_A = $library1->{branchcode};
524
$library_B = $library2->{branchcode};
525
$library_B = $library2->{branchcode};
Lines 630-636 CancelReserve( { reserve_id => $reserve_id } ); Link Here
630
# End testing hold_fulfillment_policy
631
# End testing hold_fulfillment_policy
631
632
632
# Test hold itemtype limit
633
# Test hold itemtype limit
633
C4::Context->set_preference( "UseTransportCostMatrix", 0 );
634
t::lib::Mocks::mock_preference( "UseTransportCostMatrix", 0 );
634
my $wrong_itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } })->{itemtype};
635
my $wrong_itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } })->{itemtype};
635
my $right_itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } })->{itemtype};
636
my $right_itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } })->{itemtype};
636
$borrowernumber = $borrower3->{borrowernumber};
637
$borrowernumber = $borrower3->{borrowernumber};
(-)a/t/db_dependent/Items.t (-2 / +2 lines)
Lines 93-102 subtest 'General Add, Get and Del tests' => sub { Link Here
93
    is( $getitem->{location}, 'CART', "The location should have been set to CART" );
93
    is( $getitem->{location}, 'CART', "The location should have been set to CART" );
94
    is( $getitem->{permanent_location}, $location, "The permanent_location should not have been set to CART" );
94
    is( $getitem->{permanent_location}, $location, "The permanent_location should not have been set to CART" );
95
95
96
    C4::Context->set_preference('item-level_itypes', '1');
96
    t::lib::Mocks::mock_preference('item-level_itypes', '1');
97
    $getitem = GetItem($itemnumber);
97
    $getitem = GetItem($itemnumber);
98
    is( $getitem->{itype}, $itemtype->{itemtype}, "Itemtype set correctly when using item_level-itypes" );
98
    is( $getitem->{itype}, $itemtype->{itemtype}, "Itemtype set correctly when using item_level-itypes" );
99
    C4::Context->set_preference('item-level_itypes', '0');
99
    t::lib::Mocks::mock_preference('item-level_itypes', '0');
100
    $getitem = GetItem($itemnumber);
100
    $getitem = GetItem($itemnumber);
101
    is( $getitem->{itype}, undef, "Itemtype set correctly when not using item_level-itypes" );
101
    is( $getitem->{itype}, undef, "Itemtype set correctly when not using item_level-itypes" );
102
102
(-)a/t/db_dependent/Template/Plugin/Branches.t (-3 / +3 lines)
Lines 22-27 use C4::Context; Link Here
22
use Koha::Database;
22
use Koha::Database;
23
23
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
25
use t::lib::Mocks;
25
26
26
BEGIN {
27
BEGIN {
27
    use_ok('Koha::Template::Plugin::Branches');
28
    use_ok('Koha::Template::Plugin::Branches');
Lines 63-69 C4::Context->set_userenv(123, 'userid', 'usercnum', 'First name', 'Surname', 'MY Link Here
63
$library = $plugin->GetLoggedInBranchcode();
64
$library = $plugin->GetLoggedInBranchcode();
64
is($library, 'MYLIBRARY', 'GetLoggedInBranchcode() returns active library');
65
is($library, 'MYLIBRARY', 'GetLoggedInBranchcode() returns active library');
65
66
66
C4::Context->set_preference( 'IndependentBranches', 0 );
67
t::lib::Mocks::mock_preference( 'IndependentBranches', 0 );
67
my $libraries = $plugin->all();
68
my $libraries = $plugin->all();
68
ok( scalar(@$libraries) > 1, 'If IndependentBranches is not set, all libraries should be returned' );
69
ok( scalar(@$libraries) > 1, 'If IndependentBranches is not set, all libraries should be returned' );
69
is( grep ( { $_->{branchcode} eq 'MYLIBRARY'  and $_->{selected} == 1 } @$libraries ),       1, 'Without selected parameter, my library should be preselected' );
70
is( grep ( { $_->{branchcode} eq 'MYLIBRARY'  and $_->{selected} == 1 } @$libraries ),       1, 'Without selected parameter, my library should be preselected' );
Lines 74-80 is( grep ( { $_->{branchcode} eq 'ANOTHERLIB' and $_->{selected} == 1 } @$librar Link Here
74
$libraries = $plugin->all( { selected => '' } );
75
$libraries = $plugin->all( { selected => '' } );
75
is( grep ( { exists $_->{selected} } @$libraries ), 0, 'With selected parameter set to an empty string, no library should be preselected' );
76
is( grep ( { exists $_->{selected} } @$libraries ), 0, 'With selected parameter set to an empty string, no library should be preselected' );
76
77
77
C4::Context->set_preference( 'IndependentBranches', 1 );
78
t::lib::Mocks::mock_preference( 'IndependentBranches', 1 );
78
$libraries = $plugin->all();
79
$libraries = $plugin->all();
79
is( scalar(@$libraries), 1, 'If IndependentBranches is set, only 1 library should be returned' );
80
is( scalar(@$libraries), 1, 'If IndependentBranches is set, only 1 library should be returned' );
80
$libraries = $plugin->all( { unfiltered => 1 } );
81
$libraries = $plugin->all( { unfiltered => 1 } );
81
- 

Return to bug 17633