Lines 96-102
subtest 'no rules exist' => sub {
Link Here
|
96 |
}; |
96 |
}; |
97 |
|
97 |
|
98 |
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub { |
98 |
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub { |
99 |
plan tests => 4; |
99 |
plan tests => 8; |
100 |
Koha::CirculationRules->set_rules( |
100 |
Koha::CirculationRules->set_rules( |
101 |
{ |
101 |
{ |
102 |
branchcode => $branch->{branchcode}, |
102 |
branchcode => $branch->{branchcode}, |
Lines 109-116
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
109 |
}, |
109 |
}, |
110 |
); |
110 |
); |
111 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
111 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
|
|
112 |
|
113 |
my $data = C4::Circulation::TooMany( $patron, $item ); |
114 |
my $rule = delete $data->{circulation_rule}; |
115 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
112 |
is_deeply( |
116 |
is_deeply( |
113 |
C4::Circulation::TooMany( $patron, $item ), |
117 |
$data, |
114 |
{ |
118 |
{ |
115 |
reason => 'TOO_MANY_CHECKOUTS', |
119 |
reason => 'TOO_MANY_CHECKOUTS', |
116 |
count => 0, |
120 |
count => 0, |
Lines 118-125
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
118 |
}, |
122 |
}, |
119 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
123 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
120 |
); |
124 |
); |
|
|
125 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
126 |
$rule = delete $data->{circulation_rule}; |
127 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
121 |
is_deeply( |
128 |
is_deeply( |
122 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
129 |
$data, |
123 |
{ |
130 |
{ |
124 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
131 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
125 |
count => 0, |
132 |
count => 0, |
Lines 129-136
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
129 |
); |
136 |
); |
130 |
|
137 |
|
131 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
138 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
|
|
139 |
$data = C4::Circulation::TooMany( $patron, $item ); |
140 |
$rule = delete $data->{circulation_rule}; |
141 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
132 |
is_deeply( |
142 |
is_deeply( |
133 |
C4::Circulation::TooMany( $patron, $item ), |
143 |
$data, |
134 |
{ |
144 |
{ |
135 |
reason => 'TOO_MANY_CHECKOUTS', |
145 |
reason => 'TOO_MANY_CHECKOUTS', |
136 |
count => 0, |
146 |
count => 0, |
Lines 138-145
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
138 |
}, |
148 |
}, |
139 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
149 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
140 |
); |
150 |
); |
|
|
151 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
152 |
$rule = delete $data->{circulation_rule}; |
153 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
141 |
is_deeply( |
154 |
is_deeply( |
142 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
155 |
$data, |
143 |
{ |
156 |
{ |
144 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
157 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
145 |
count => 0, |
158 |
count => 0, |
Lines 152-158
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
152 |
}; |
165 |
}; |
153 |
|
166 |
|
154 |
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub { |
167 |
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub { |
155 |
plan tests => 4; |
168 |
plan tests => 8; |
156 |
|
169 |
|
157 |
Koha::CirculationRules->set_rules( |
170 |
Koha::CirculationRules->set_rules( |
158 |
{ |
171 |
{ |
Lines 168-175
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub {
Link Here
|
168 |
|
181 |
|
169 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string() ); |
182 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string() ); |
170 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
183 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
|
|
184 |
my $data = C4::Circulation::TooMany( $patron, $item ); |
185 |
my $rule = delete $data->{circulation_rule}; |
186 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
171 |
is_deeply( |
187 |
is_deeply( |
172 |
C4::Circulation::TooMany( $patron, $item ), |
188 |
$data, |
173 |
{ |
189 |
{ |
174 |
reason => 'TOO_MANY_CHECKOUTS', |
190 |
reason => 'TOO_MANY_CHECKOUTS', |
175 |
count => 1, |
191 |
count => 1, |
Lines 177-191
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub {
Link Here
|
177 |
}, |
193 |
}, |
178 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
194 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
179 |
); |
195 |
); |
180 |
is( |
196 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ); |
181 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
197 |
$rule = delete $data->{circulation_rule}; |
182 |
undef, |
198 |
is( ref $rule, '', 'No circulation rule was returned' ); |
|
|
199 |
is_deeply( |
200 |
$data, |
201 |
{}, |
183 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
202 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
184 |
); |
203 |
); |
185 |
|
204 |
|
186 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
205 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
|
|
206 |
$data = C4::Circulation::TooMany( $patron, $item ); |
207 |
$rule = delete $data->{circulation_rule}; |
208 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
187 |
is_deeply( |
209 |
is_deeply( |
188 |
C4::Circulation::TooMany( $patron, $item ), |
210 |
$data, |
189 |
{ |
211 |
{ |
190 |
reason => 'TOO_MANY_CHECKOUTS', |
212 |
reason => 'TOO_MANY_CHECKOUTS', |
191 |
count => 1, |
213 |
count => 1, |
Lines 193-200
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub {
Link Here
|
193 |
}, |
215 |
}, |
194 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
216 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
195 |
); |
217 |
); |
|
|
218 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ); |
219 |
$rule = delete $data->{circulation_rule}; |
220 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
196 |
is_deeply( |
221 |
is_deeply( |
197 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
222 |
$data, |
198 |
{ |
223 |
{ |
199 |
reason => 'TOO_MANY_CHECKOUTS', |
224 |
reason => 'TOO_MANY_CHECKOUTS', |
200 |
count => 1, |
225 |
count => 1, |
Lines 248-254
subtest '1 Issuingrule exist 1 1: issue is allowed' => sub {
Link Here
|
248 |
}; |
273 |
}; |
249 |
|
274 |
|
250 |
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub { |
275 |
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub { |
251 |
plan tests => 5; |
276 |
plan tests => 9; |
252 |
Koha::CirculationRules->set_rules( |
277 |
Koha::CirculationRules->set_rules( |
253 |
{ |
278 |
{ |
254 |
branchcode => $branch->{branchcode}, |
279 |
branchcode => $branch->{branchcode}, |
Lines 265-272
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub {
Link Here
|
265 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
290 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
266 |
|
291 |
|
267 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
292 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
|
|
293 |
my $data = C4::Circulation::TooMany( $patron, $item ); |
294 |
my $rule = delete $data->{circulation_rule}; |
295 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
268 |
is_deeply( |
296 |
is_deeply( |
269 |
C4::Circulation::TooMany( $patron, $item ), |
297 |
$data, |
270 |
{ |
298 |
{ |
271 |
reason => 'TOO_MANY_CHECKOUTS', |
299 |
reason => 'TOO_MANY_CHECKOUTS', |
272 |
count => 1, |
300 |
count => 1, |
Lines 274-288
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub {
Link Here
|
274 |
}, |
302 |
}, |
275 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
303 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
276 |
); |
304 |
); |
277 |
is( |
305 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ); |
278 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
306 |
$rule = delete $data->{circulation_rule}; |
279 |
undef, |
307 |
is( ref $rule, '', 'No circulation rule was returned' ); |
|
|
308 |
is_deeply( |
309 |
$data, |
310 |
{}, |
280 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
311 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
281 |
); |
312 |
); |
282 |
|
313 |
|
283 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
314 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
|
|
315 |
$data = C4::Circulation::TooMany( $patron, $item ); |
316 |
$rule = delete $data->{circulation_rule}; |
317 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
284 |
is_deeply( |
318 |
is_deeply( |
285 |
C4::Circulation::TooMany( $patron, $item ), |
319 |
$data, |
286 |
{ |
320 |
{ |
287 |
reason => 'TOO_MANY_CHECKOUTS', |
321 |
reason => 'TOO_MANY_CHECKOUTS', |
288 |
count => 1, |
322 |
count => 1, |
Lines 290-297
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub {
Link Here
|
290 |
}, |
324 |
}, |
291 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
325 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
292 |
); |
326 |
); |
|
|
327 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ); |
328 |
$rule = delete $data->{circulation_rule}; |
329 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
293 |
is_deeply( |
330 |
is_deeply( |
294 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
331 |
$data, |
295 |
{ |
332 |
{ |
296 |
reason => 'TOO_MANY_CHECKOUTS', |
333 |
reason => 'TOO_MANY_CHECKOUTS', |
297 |
count => 1, |
334 |
count => 1, |
Lines 304-310
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub {
Link Here
|
304 |
}; |
341 |
}; |
305 |
|
342 |
|
306 |
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub { |
343 |
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub { |
307 |
plan tests => 5; |
344 |
plan tests => 8; |
308 |
Koha::CirculationRules->set_rules( |
345 |
Koha::CirculationRules->set_rules( |
309 |
{ |
346 |
{ |
310 |
branchcode => $branch->{branchcode}, |
347 |
branchcode => $branch->{branchcode}, |
Lines 326-333
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub {
Link Here
|
326 |
undef, |
363 |
undef, |
327 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
364 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
328 |
); |
365 |
); |
|
|
366 |
my $data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ); |
367 |
my $rule = delete $data->{circulation_rule}; |
368 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
329 |
is_deeply( |
369 |
is_deeply( |
330 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
370 |
$data, |
331 |
{ |
371 |
{ |
332 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
372 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
333 |
count => 1, |
373 |
count => 1, |
Lines 337-344
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub {
Link Here
|
337 |
); |
377 |
); |
338 |
|
378 |
|
339 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
379 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
|
|
380 |
$data = C4::Circulation::TooMany( $patron, $item ); |
381 |
$rule = delete $data->{circulation_rule}; |
382 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
340 |
is_deeply( |
383 |
is_deeply( |
341 |
C4::Circulation::TooMany( $patron, $item ), |
384 |
$data, |
342 |
{ |
385 |
{ |
343 |
reason => 'TOO_MANY_CHECKOUTS', |
386 |
reason => 'TOO_MANY_CHECKOUTS', |
344 |
count => 1, |
387 |
count => 1, |
Lines 346-353
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub {
Link Here
|
346 |
}, |
389 |
}, |
347 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
390 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
348 |
); |
391 |
); |
|
|
392 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ); |
393 |
$rule = delete $data->{circulation_rule}; |
394 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
349 |
is_deeply( |
395 |
is_deeply( |
350 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
396 |
$data, |
351 |
{ |
397 |
{ |
352 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
398 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
353 |
count => 1, |
399 |
count => 1, |
Lines 363-369
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
363 |
# Note: the same test coul be done for |
409 |
# Note: the same test coul be done for |
364 |
# DefaultBorrowerCircRule, DefaultBranchCircRule, DefaultBranchItemRule ans DefaultCircRule.pm |
410 |
# DefaultBorrowerCircRule, DefaultBranchCircRule, DefaultBranchItemRule ans DefaultCircRule.pm |
365 |
|
411 |
|
366 |
plan tests => 10; |
412 |
plan tests => 18; |
367 |
Koha::CirculationRules->set_rules( |
413 |
Koha::CirculationRules->set_rules( |
368 |
{ |
414 |
{ |
369 |
branchcode => $branch->{branchcode}, |
415 |
branchcode => $branch->{branchcode}, |
Lines 380-387
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
380 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
426 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
381 |
|
427 |
|
382 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
428 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
|
|
429 |
my $data = C4::Circulation::TooMany( $patron, $item ); |
430 |
my $rule = delete $data->{circulation_rule}; |
431 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
383 |
is_deeply( |
432 |
is_deeply( |
384 |
C4::Circulation::TooMany( $patron, $item ), |
433 |
$data, |
385 |
{ |
434 |
{ |
386 |
reason => 'TOO_MANY_CHECKOUTS', |
435 |
reason => 'TOO_MANY_CHECKOUTS', |
387 |
count => 1, |
436 |
count => 1, |
Lines 389-403
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
389 |
}, |
438 |
}, |
390 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
439 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
391 |
); |
440 |
); |
392 |
is( |
441 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
393 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
442 |
$rule = delete $data->{circulation_rule}; |
394 |
undef, |
443 |
is( ref $rule, '', 'No circulation rule was returned' ); |
|
|
444 |
is_deeply( |
445 |
$data, |
446 |
{}, |
395 |
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
447 |
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
396 |
); |
448 |
); |
397 |
|
449 |
|
398 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
450 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
|
|
451 |
$data = C4::Circulation::TooMany( $patron, $item ); |
452 |
$rule = delete $data->{circulation_rule}; |
453 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
399 |
is_deeply( |
454 |
is_deeply( |
400 |
C4::Circulation::TooMany( $patron, $item ), |
455 |
$data, |
401 |
{ |
456 |
{ |
402 |
reason => 'TOO_MANY_CHECKOUTS', |
457 |
reason => 'TOO_MANY_CHECKOUTS', |
403 |
count => 1, |
458 |
count => 1, |
Lines 405-412
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
405 |
}, |
460 |
}, |
406 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
461 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
407 |
); |
462 |
); |
|
|
463 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
464 |
$rule = delete $data->{circulation_rule}; |
465 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
408 |
is_deeply( |
466 |
is_deeply( |
409 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
467 |
$data, |
410 |
{ |
468 |
{ |
411 |
reason => 'TOO_MANY_CHECKOUTS', |
469 |
reason => 'TOO_MANY_CHECKOUTS', |
412 |
count => 1, |
470 |
count => 1, |
Lines 432-444
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
432 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
490 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
433 |
|
491 |
|
434 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
492 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
|
|
493 |
$data = C4::Circulation::TooMany( $patron, $item ); |
494 |
$rule = delete $data->{circulation_rule}; |
495 |
is( ref $rule, '', 'No circulation rule was returned' ); |
435 |
is( |
496 |
is( |
436 |
C4::Circulation::TooMany( $patron, $item ), |
497 |
keys %$data, |
437 |
undef, |
498 |
0, |
438 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
499 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
439 |
); |
500 |
); |
|
|
501 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
502 |
$rule = delete $data->{circulation_rule}; |
503 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
440 |
is_deeply( |
504 |
is_deeply( |
441 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
505 |
$data, |
442 |
{ |
506 |
{ |
443 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
507 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
444 |
count => 1, |
508 |
count => 1, |
Lines 448-455
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
448 |
); |
512 |
); |
449 |
|
513 |
|
450 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
514 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
|
|
515 |
$data = C4::Circulation::TooMany( $patron, $item ); |
516 |
$rule = delete $data->{circulation_rule}; |
517 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
451 |
is_deeply( |
518 |
is_deeply( |
452 |
C4::Circulation::TooMany( $patron, $item ), |
519 |
$data, |
453 |
{ |
520 |
{ |
454 |
reason => 'TOO_MANY_CHECKOUTS', |
521 |
reason => 'TOO_MANY_CHECKOUTS', |
455 |
count => 1, |
522 |
count => 1, |
Lines 457-464
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
457 |
}, |
524 |
}, |
458 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
525 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
459 |
); |
526 |
); |
|
|
527 |
$data = C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
528 |
$rule = delete $data->{circulation_rule}; |
529 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
460 |
is_deeply( |
530 |
is_deeply( |
461 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
531 |
$data, |
462 |
{ |
532 |
{ |
463 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
533 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
464 |
count => 1, |
534 |
count => 1, |
Lines 471-477
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
471 |
}; |
541 |
}; |
472 |
|
542 |
|
473 |
subtest 'General vs specific rules limit quantity correctly' => sub { |
543 |
subtest 'General vs specific rules limit quantity correctly' => sub { |
474 |
plan tests => 10; |
544 |
plan tests => 18; |
475 |
|
545 |
|
476 |
t::lib::Mocks::mock_preference('CircControl', 'ItemHomeLibrary'); |
546 |
t::lib::Mocks::mock_preference('CircControl', 'ItemHomeLibrary'); |
477 |
my $branch = $builder->build({source => 'Branch',}); |
547 |
my $branch = $builder->build({source => 'Branch',}); |
Lines 547-554
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
547 |
t::lib::Mocks::mock_userenv({ branchcode => $branch->{branchcode} }); |
617 |
t::lib::Mocks::mock_userenv({ branchcode => $branch->{branchcode} }); |
548 |
my $issue = C4::Circulation::AddIssue( $patron, $issue_item->barcode, dt_from_string() ); |
618 |
my $issue = C4::Circulation::AddIssue( $patron, $issue_item->barcode, dt_from_string() ); |
549 |
# We checkout one item |
619 |
# We checkout one item |
|
|
620 |
my $data = C4::Circulation::TooMany( $patron, $branch_item ); |
621 |
my $rule = delete $data->{circulation_rule}; |
622 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
550 |
is_deeply( |
623 |
is_deeply( |
551 |
C4::Circulation::TooMany( $patron, $branch_item ), |
624 |
$data, |
552 |
{ |
625 |
{ |
553 |
reason => 'TOO_MANY_CHECKOUTS', |
626 |
reason => 'TOO_MANY_CHECKOUTS', |
554 |
count => 1, |
627 |
count => 1, |
Lines 562-569
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
562 |
$issue_item->biblio->biblioitem->itemtype($itemtype->{itemtype})->store; |
635 |
$issue_item->biblio->biblioitem->itemtype($itemtype->{itemtype})->store; |
563 |
$branch_item->biblio->biblioitem->itemtype($itemtype->{itemtype})->store; |
636 |
$branch_item->biblio->biblioitem->itemtype($itemtype->{itemtype})->store; |
564 |
# We checkout one item |
637 |
# We checkout one item |
|
|
638 |
$data = C4::Circulation::TooMany( $patron, $branch_item ); |
639 |
$rule = delete $data->{circulation_rule}; |
640 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
565 |
is_deeply( |
641 |
is_deeply( |
566 |
C4::Circulation::TooMany( $patron, $branch_item ), |
642 |
$data, |
567 |
{ |
643 |
{ |
568 |
reason => 'TOO_MANY_CHECKOUTS', |
644 |
reason => 'TOO_MANY_CHECKOUTS', |
569 |
count => 1, |
645 |
count => 1, |
Lines 596-603
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
596 |
|
672 |
|
597 |
# If circcontrol is PatronLibrary we count all the patron's loan, regardless of branch |
673 |
# If circcontrol is PatronLibrary we count all the patron's loan, regardless of branch |
598 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
674 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
|
|
675 |
$data = C4::Circulation::TooMany( $patron, $branch_item ); |
676 |
$rule = delete $data->{circulation_rule}; |
677 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
599 |
is_deeply( |
678 |
is_deeply( |
600 |
C4::Circulation::TooMany( $patron, $branch_item ), |
679 |
$data, |
601 |
{ |
680 |
{ |
602 |
reason => 'TOO_MANY_CHECKOUTS', |
681 |
reason => 'TOO_MANY_CHECKOUTS', |
603 |
count => 1, |
682 |
count => 1, |
Lines 615-622
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
615 |
homebranch => $branch->{branchcode}, |
694 |
homebranch => $branch->{branchcode}, |
616 |
holdingbranch => $branch->{branchcode} |
695 |
holdingbranch => $branch->{branchcode} |
617 |
}); |
696 |
}); |
|
|
697 |
$data = C4::Circulation::TooMany( $patron, $branch_item_2 ); |
698 |
$rule = delete $data->{circulation_rule}; |
699 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
618 |
is_deeply( |
700 |
is_deeply( |
619 |
C4::Circulation::TooMany( $patron, $branch_item_2 ), |
701 |
$data, |
620 |
{ |
702 |
{ |
621 |
reason => 'TOO_MANY_CHECKOUTS', |
703 |
reason => 'TOO_MANY_CHECKOUTS', |
622 |
count => 1, |
704 |
count => 1, |
Lines 629-636
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
629 |
my $item_2 = $builder->build_sample_item({ |
711 |
my $item_2 = $builder->build_sample_item({ |
630 |
itype => $itemtype->{itemtype}, |
712 |
itype => $itemtype->{itemtype}, |
631 |
}); |
713 |
}); |
|
|
714 |
$data = C4::Circulation::TooMany( $patron, $item_2 ); |
715 |
$rule = delete $data->{circulation_rule}; |
716 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
632 |
is_deeply( |
717 |
is_deeply( |
633 |
C4::Circulation::TooMany( $patron, $item_2 ), |
718 |
$data, |
634 |
{ |
719 |
{ |
635 |
reason => 'TOO_MANY_CHECKOUTS', |
720 |
reason => 'TOO_MANY_CHECKOUTS', |
636 |
count => 2, |
721 |
count => 2, |
Lines 639-646
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
639 |
'We are only allowed one for general rule, and have two' |
724 |
'We are only allowed one for general rule, and have two' |
640 |
); |
725 |
); |
641 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
726 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
|
|
727 |
$data = C4::Circulation::TooMany( $patron, $item_2 ); |
728 |
$rule = delete $data->{circulation_rule}; |
729 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
642 |
is_deeply( |
730 |
is_deeply( |
643 |
C4::Circulation::TooMany( $patron, $item_2 ), |
731 |
$data, |
644 |
{ |
732 |
{ |
645 |
reason => 'TOO_MANY_CHECKOUTS', |
733 |
reason => 'TOO_MANY_CHECKOUTS', |
646 |
count => 2, |
734 |
count => 2, |
Lines 650-657
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
650 |
); |
738 |
); |
651 |
|
739 |
|
652 |
t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary'); |
740 |
t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary'); |
|
|
741 |
$data = C4::Circulation::TooMany( $patron, $item_2 ); |
742 |
$rule = delete $data->{circulation_rule}; |
743 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
653 |
is_deeply( |
744 |
is_deeply( |
654 |
C4::Circulation::TooMany( $patron, $item_2 ), |
745 |
$data, |
655 |
{ |
746 |
{ |
656 |
reason => 'TOO_MANY_CHECKOUTS', |
747 |
reason => 'TOO_MANY_CHECKOUTS', |
657 |
count => 2, |
748 |
count => 2, |
Lines 661-668
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
661 |
); |
752 |
); |
662 |
|
753 |
|
663 |
t::lib::Mocks::mock_userenv({ branchcode => $branch2->{branchcode} }); |
754 |
t::lib::Mocks::mock_userenv({ branchcode => $branch2->{branchcode} }); |
|
|
755 |
$data = C4::Circulation::TooMany( $patron, $item_2 ); |
756 |
$rule = delete $data->{circulation_rule}; |
757 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
664 |
is_deeply( |
758 |
is_deeply( |
665 |
C4::Circulation::TooMany( $patron, $item_2 ), |
759 |
$data, |
666 |
{ |
760 |
{ |
667 |
reason => 'TOO_MANY_CHECKOUTS', |
761 |
reason => 'TOO_MANY_CHECKOUTS', |
668 |
count => 2, |
762 |
count => 2, |
Lines 718-724
subtest 'empty string means unlimited' => sub {
Link Here
|
718 |
}; |
812 |
}; |
719 |
|
813 |
|
720 |
subtest 'itemtype group tests' => sub { |
814 |
subtest 'itemtype group tests' => sub { |
721 |
plan tests => 13; |
815 |
plan tests => 17; |
722 |
|
816 |
|
723 |
t::lib::Mocks::mock_preference( 'CircControl', 'ItemHomeLibrary' ); |
817 |
t::lib::Mocks::mock_preference( 'CircControl', 'ItemHomeLibrary' ); |
724 |
Koha::CirculationRules->set_rules( |
818 |
Koha::CirculationRules->set_rules( |
Lines 844-851
subtest 'itemtype group tests' => sub {
Link Here
|
844 |
} |
938 |
} |
845 |
); |
939 |
); |
846 |
|
940 |
|
|
|
941 |
my $data = C4::Circulation::TooMany( $patron, $item ); |
942 |
my $rule = delete $data->{circulation_rule}; |
943 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
847 |
is_deeply( |
944 |
is_deeply( |
848 |
C4::Circulation::TooMany( $patron, $item ), |
945 |
$data, |
849 |
{ |
946 |
{ |
850 |
reason => 'TOO_MANY_CHECKOUTS', |
947 |
reason => 'TOO_MANY_CHECKOUTS', |
851 |
count => 1, |
948 |
count => 1, |
Lines 885-892
subtest 'itemtype group tests' => sub {
Link Here
|
885 |
|
982 |
|
886 |
#patron has 1 checkout of childitype1 and 1 checkout of childitype2 |
983 |
#patron has 1 checkout of childitype1 and 1 checkout of childitype2 |
887 |
|
984 |
|
|
|
985 |
$data = C4::Circulation::TooMany( $patron, $item ); |
986 |
$rule = delete $data->{circulation_rule}; |
987 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
888 |
is_deeply( |
988 |
is_deeply( |
889 |
C4::Circulation::TooMany( $patron, $item ), |
989 |
$data, |
890 |
{ |
990 |
{ |
891 |
reason => 'TOO_MANY_CHECKOUTS', |
991 |
reason => 'TOO_MANY_CHECKOUTS', |
892 |
count => 2, |
992 |
count => 2, |
Lines 903-910
subtest 'itemtype group tests' => sub {
Link Here
|
903 |
} |
1003 |
} |
904 |
); |
1004 |
); |
905 |
|
1005 |
|
|
|
1006 |
$data = C4::Circulation::TooMany( $patron, $parent_item ); |
1007 |
$rule = delete $data->{circulation_rule}; |
1008 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
906 |
is_deeply( |
1009 |
is_deeply( |
907 |
C4::Circulation::TooMany( $patron, $parent_item ), |
1010 |
$data, |
908 |
{ |
1011 |
{ |
909 |
reason => 'TOO_MANY_CHECKOUTS', |
1012 |
reason => 'TOO_MANY_CHECKOUTS', |
910 |
count => 2, |
1013 |
count => 2, |
Lines 968-975
subtest 'itemtype group tests' => sub {
Link Here
|
968 |
|
1071 |
|
969 |
#patron has 1 checkout of childitype 1 and 3 of childitype2 |
1072 |
#patron has 1 checkout of childitype 1 and 3 of childitype2 |
970 |
|
1073 |
|
|
|
1074 |
$data = C4::Circulation::TooMany( $patron, $item_3 ); |
1075 |
$rule = delete $data->{circulation_rule}; |
1076 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
971 |
is_deeply( |
1077 |
is_deeply( |
972 |
C4::Circulation::TooMany( $patron, $item_3 ), |
1078 |
$data, |
973 |
{ |
1079 |
{ |
974 |
reason => 'TOO_MANY_CHECKOUTS', |
1080 |
reason => 'TOO_MANY_CHECKOUTS', |
975 |
max_allowed => 4, |
1081 |
max_allowed => 4, |
Lines 982-988
subtest 'itemtype group tests' => sub {
Link Here
|
982 |
}; |
1088 |
}; |
983 |
|
1089 |
|
984 |
subtest 'HomeOrHoldingBranch is used' => sub { |
1090 |
subtest 'HomeOrHoldingBranch is used' => sub { |
985 |
plan tests => 2; |
1091 |
plan tests => 4; |
986 |
|
1092 |
|
987 |
t::lib::Mocks::mock_preference( 'CircControl', 'ItemHomeLibrary' ); |
1093 |
t::lib::Mocks::mock_preference( 'CircControl', 'ItemHomeLibrary' ); |
988 |
|
1094 |
|
Lines 1020-1027
subtest 'HomeOrHoldingBranch is used' => sub {
Link Here
|
1020 |
|
1126 |
|
1021 |
t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'homebranch'); |
1127 |
t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'homebranch'); |
1022 |
|
1128 |
|
|
|
1129 |
my $data = C4::Circulation::TooMany( $patron, $item_1 ); |
1130 |
my $rule = delete $data->{circulation_rule}; |
1131 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
1023 |
is_deeply( |
1132 |
is_deeply( |
1024 |
C4::Circulation::TooMany( $patron, $item_1 ), |
1133 |
$data, |
1025 |
{ |
1134 |
{ |
1026 |
reason => 'TOO_MANY_CHECKOUTS', |
1135 |
reason => 'TOO_MANY_CHECKOUTS', |
1027 |
max_allowed => 0, |
1136 |
max_allowed => 0, |
Lines 1032-1039
subtest 'HomeOrHoldingBranch is used' => sub {
Link Here
|
1032 |
|
1141 |
|
1033 |
t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'holdingbranch'); |
1142 |
t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'holdingbranch'); |
1034 |
|
1143 |
|
|
|
1144 |
$data = C4::Circulation::TooMany( $patron, $item_1 ); |
1145 |
$rule = delete $data->{circulation_rule}; |
1146 |
is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); |
1035 |
is_deeply( |
1147 |
is_deeply( |
1036 |
C4::Circulation::TooMany( $patron, $item_1 ), |
1148 |
$data, |
1037 |
{ |
1149 |
{ |
1038 |
reason => 'TOO_MANY_CHECKOUTS', |
1150 |
reason => 'TOO_MANY_CHECKOUTS', |
1039 |
max_allowed => 1, |
1151 |
max_allowed => 1, |
1040 |
- |
|
|