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

(-)a/t/db_dependent/DecreaseLoanHighHolds.t (-18 / +13 lines)
Lines 127-136 t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsValue', 1 ); Link Here
127
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl',        'static' );
127
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl',        'static' );
128
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
128
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
129
129
130
my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, barcode => $item->barcode };
130
my $data = C4::Circulation::checkHighHolds( $item, $patron );
131
my $patron_hr = { borrowernumber => $patron->id, branchcode => $library->{branchcode} };
132
133
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
134
is( $data->{exceeded},        1,          "Static mode should exceed threshold" );
131
is( $data->{exceeded},        1,          "Static mode should exceed threshold" );
135
is( $data->{outstanding},     6,          "Should have 6 outstanding holds" );
132
is( $data->{outstanding},     6,          "Should have 6 outstanding holds" );
136
is( $data->{duration},        0,          "Should have duration of 0 because of specific circulation rules" );
133
is( $data->{duration},        0,          "Should have duration of 0 because of specific circulation rules" );
Lines 151-157 Koha::CirculationRules->set_rules( Link Here
151
    }
148
    }
152
);
149
);
153
150
154
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
151
$data = C4::Circulation::checkHighHolds( $item, $patron );
155
is( $data->{duration}, 1, "Should have a duration of 1 because no specific circulation rules so defaults to system preference" );
152
is( $data->{duration}, 1, "Should have a duration of 1 because no specific circulation rules so defaults to system preference" );
156
153
157
my $duedate = $data->{due_date};
154
my $duedate = $data->{due_date};
Lines 160-166 is($duedate->min, $orig_due->min, 'New due minute is equal to original due minut Link Here
160
is($duedate->sec, 0, 'New due date second is zero.');
157
is($duedate->sec, 0, 'New due date second is zero.');
161
158
162
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl', 'dynamic' );
159
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl', 'dynamic' );
163
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
160
$data = C4::Circulation::checkHighHolds( $item, $patron );
164
is( $data->{exceeded}, 0, "Should not exceed threshold" );
161
is( $data->{exceeded}, 0, "Should not exceed threshold" );
165
162
166
163
Lines 177-189 for my $i ( 5 .. 10 ) { Link Here
177
}
174
}
178
175
179
# 12 holds, threshold is 1 over 10 holdable items = 11
176
# 12 holds, threshold is 1 over 10 holdable items = 11
180
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
177
$data = C4::Circulation::checkHighHolds( $item, $patron );
181
is( $data->{exceeded}, 1, "Should exceed threshold of 1" );
178
is( $data->{exceeded}, 1, "Should exceed threshold of 1" );
182
is( $data->{outstanding}, 12, "Should exceed threshold of 1" );
179
is( $data->{outstanding}, 12, "Should exceed threshold of 1" );
183
180
184
# 12 holds, threshold is 2 over 10 holdable items = 12 (equal is okay)
181
# 12 holds, threshold is 2 over 10 holdable items = 12 (equal is okay)
185
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsValue', 2 );
182
t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsValue', 2 );
186
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
183
$data = C4::Circulation::checkHighHolds( $item, $patron );
187
is( $data->{exceeded}, 0, "Should not exceed threshold of 2" );
184
is( $data->{exceeded}, 0, "Should not exceed threshold of 2" );
188
185
189
my $unholdable = pop(@items);
186
my $unholdable = pop(@items);
Lines 191-197 $unholdable->damaged(-1); Link Here
191
$unholdable->store();
188
$unholdable->store();
192
189
193
# 12 holds, threshold is 2 over 9 holdable items = 11
190
# 12 holds, threshold is 2 over 9 holdable items = 11
194
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
191
$data = C4::Circulation::checkHighHolds( $item, $patron );
195
is( $data->{exceeded}, 1, "Should exceed threshold with one damaged item" );
192
is( $data->{exceeded}, 1, "Should exceed threshold with one damaged item" );
196
193
197
$unholdable->damaged(0);
194
$unholdable->damaged(0);
Lines 199-205 $unholdable->itemlost(-1); Link Here
199
$unholdable->store();
196
$unholdable->store();
200
197
201
# 12 holds, threshold is 2 over 9 holdable items = 11
198
# 12 holds, threshold is 2 over 9 holdable items = 11
202
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
199
$data = C4::Circulation::checkHighHolds( $item, $patron );
203
is( $data->{exceeded}, 1, "Should exceed threshold with one lost item" );
200
is( $data->{exceeded}, 1, "Should exceed threshold with one lost item" );
204
201
205
$unholdable->itemlost(0);
202
$unholdable->itemlost(0);
Lines 207-213 $unholdable->notforloan(-1); Link Here
207
$unholdable->store();
204
$unholdable->store();
208
205
209
# 12 holds, threshold is 2 over 9 holdable items = 11
206
# 12 holds, threshold is 2 over 9 holdable items = 11
210
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
207
$data = C4::Circulation::checkHighHolds( $item, $patron );
211
is( $data->{exceeded}, 1, "Should exceed threshold with one notforloan item" );
208
is( $data->{exceeded}, 1, "Should exceed threshold with one notforloan item" );
212
209
213
$unholdable->notforloan(0);
210
$unholdable->notforloan(0);
Lines 215-236 $unholdable->withdrawn(-1); Link Here
215
$unholdable->store();
212
$unholdable->store();
216
213
217
# 12 holds, threshold is 2 over 9 holdable items = 11
214
# 12 holds, threshold is 2 over 9 holdable items = 11
218
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
215
$data = C4::Circulation::checkHighHolds( $item, $patron );
219
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
216
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
220
217
221
$patron_hold->found('F')->store;
218
$patron_hold->found('F')->store;
222
# 11 holds, threshold is 2 over 9 holdable items = 11
219
# 11 holds, threshold is 2 over 9 holdable items = 11
223
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
220
$data = C4::Circulation::checkHighHolds( $item, $patron );
224
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
221
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
225
$patron_hold->found(undef)->store;
222
$patron_hold->found(undef)->store;
226
223
227
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary');
224
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary');
228
225
229
my $patron_object = Koha::Patrons->find( $patron_hr->{borrowernumber} );
226
my ( undef, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode );
230
my ( undef, $needsconfirmation ) = CanBookBeIssued( $patron_object, $item->barcode );
231
ok( $needsconfirmation->{HIGHHOLDS}, "High holds checkout needs confirmation" );
227
ok( $needsconfirmation->{HIGHHOLDS}, "High holds checkout needs confirmation" );
232
228
233
( undef, $needsconfirmation ) = CanBookBeIssued( $patron_object, $item->barcode, undef, undef, undef, { override_high_holds => 1 } );
229
( undef, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, { override_high_holds => 1 } );
234
ok( !$needsconfirmation->{HIGHHOLDS}, "High holds checkout does not need confirmation" );
230
ok( !$needsconfirmation->{HIGHHOLDS}, "High holds checkout does not need confirmation" );
235
231
236
Koha::CirculationRules->set_rule(
232
Koha::CirculationRules->set_rule(
Lines 243-249 Koha::CirculationRules->set_rule( Link Here
243
    }
239
    }
244
);
240
);
245
241
246
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
242
$data = C4::Circulation::checkHighHolds( $item, $patron );
247
is( $data->{duration}, 2, "Circulation rules override system preferences" );
243
is( $data->{duration}, 2, "Circulation rules override system preferences" );
248
244
249
$schema->storage->txn_rollback();
245
$schema->storage->txn_rollback();
250
- 

Return to bug 29562