Lines 81-86
my $item = $builder->build({
Link Here
|
81 |
}); |
81 |
}); |
82 |
|
82 |
|
83 |
my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); |
83 |
my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); |
|
|
84 |
my $item_object = Koha::Items->find( $item->{itemnumber} ); |
84 |
t::lib::Mocks::mock_userenv( { patron => $patron_object }); |
85 |
t::lib::Mocks::mock_userenv( { patron => $patron_object }); |
85 |
|
86 |
|
86 |
# TooMany return ($current_loan_count, $max_loans_allowed) or undef |
87 |
# TooMany return ($current_loan_count, $max_loans_allowed) or undef |
Lines 90-101
t::lib::Mocks::mock_userenv( { patron => $patron_object });
Link Here
|
90 |
subtest 'no rules exist' => sub { |
91 |
subtest 'no rules exist' => sub { |
91 |
plan tests => 2; |
92 |
plan tests => 2; |
92 |
is_deeply( |
93 |
is_deeply( |
93 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
94 |
C4::Circulation::TooMany( $patron, $item_object ), |
94 |
{ reason => 'NO_RULE_DEFINED', max_allowed => 0 }, |
95 |
{ reason => 'NO_RULE_DEFINED', max_allowed => 0 }, |
95 |
'CO should not be allowed, in any cases' |
96 |
'CO should not be allowed, in any cases' |
96 |
); |
97 |
); |
97 |
is_deeply( |
98 |
is_deeply( |
98 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
99 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
99 |
{ reason => 'NO_RULE_DEFINED', max_allowed => 0 }, |
100 |
{ reason => 'NO_RULE_DEFINED', max_allowed => 0 }, |
100 |
'OSCO should not be allowed, in any cases' |
101 |
'OSCO should not be allowed, in any cases' |
101 |
); |
102 |
); |
Lines 116-122
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
116 |
); |
117 |
); |
117 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
118 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
118 |
is_deeply( |
119 |
is_deeply( |
119 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
120 |
C4::Circulation::TooMany( $patron, $item_object ), |
120 |
{ |
121 |
{ |
121 |
reason => 'TOO_MANY_CHECKOUTS', |
122 |
reason => 'TOO_MANY_CHECKOUTS', |
122 |
count => 0, |
123 |
count => 0, |
Lines 125-131
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
125 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
126 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
126 |
); |
127 |
); |
127 |
is_deeply( |
128 |
is_deeply( |
128 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
129 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
129 |
{ |
130 |
{ |
130 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
131 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
131 |
count => 0, |
132 |
count => 0, |
Lines 136-142
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
136 |
|
137 |
|
137 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
138 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
138 |
is_deeply( |
139 |
is_deeply( |
139 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
140 |
C4::Circulation::TooMany( $patron, $item_object ), |
140 |
{ |
141 |
{ |
141 |
reason => 'TOO_MANY_CHECKOUTS', |
142 |
reason => 'TOO_MANY_CHECKOUTS', |
142 |
count => 0, |
143 |
count => 0, |
Lines 145-151
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
145 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
146 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
146 |
); |
147 |
); |
147 |
is_deeply( |
148 |
is_deeply( |
148 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
149 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
149 |
{ |
150 |
{ |
150 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
151 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
151 |
count => 0, |
152 |
count => 0, |
Lines 175-181
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub {
Link Here
|
175 |
my $issue = C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string() ); |
176 |
my $issue = C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string() ); |
176 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
177 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
177 |
is_deeply( |
178 |
is_deeply( |
178 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
179 |
C4::Circulation::TooMany( $patron, $item_object ), |
179 |
{ |
180 |
{ |
180 |
reason => 'TOO_MANY_CHECKOUTS', |
181 |
reason => 'TOO_MANY_CHECKOUTS', |
181 |
count => 1, |
182 |
count => 1, |
Lines 184-197
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub {
Link Here
|
184 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
185 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
185 |
); |
186 |
); |
186 |
is( |
187 |
is( |
187 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
188 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
188 |
undef, |
189 |
undef, |
189 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
190 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
190 |
); |
191 |
); |
191 |
|
192 |
|
192 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
193 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
193 |
is_deeply( |
194 |
is_deeply( |
194 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
195 |
C4::Circulation::TooMany( $patron, $item_object ), |
195 |
{ |
196 |
{ |
196 |
reason => 'TOO_MANY_CHECKOUTS', |
197 |
reason => 'TOO_MANY_CHECKOUTS', |
197 |
count => 1, |
198 |
count => 1, |
Lines 200-206
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub {
Link Here
|
200 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
201 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
201 |
); |
202 |
); |
202 |
is_deeply( |
203 |
is_deeply( |
203 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
204 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
204 |
{ |
205 |
{ |
205 |
reason => 'TOO_MANY_CHECKOUTS', |
206 |
reason => 'TOO_MANY_CHECKOUTS', |
206 |
count => 1, |
207 |
count => 1, |
Lines 228-251
subtest '1 Issuingrule exist 1 1: issue is allowed' => sub {
Link Here
|
228 |
); |
229 |
); |
229 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
230 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
230 |
is( |
231 |
is( |
231 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
232 |
C4::Circulation::TooMany( $patron, $item_object ), |
232 |
undef, |
233 |
undef, |
233 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
234 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
234 |
); |
235 |
); |
235 |
is( |
236 |
is( |
236 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
237 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
237 |
undef, |
238 |
undef, |
238 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
239 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
239 |
); |
240 |
); |
240 |
|
241 |
|
241 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
242 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
242 |
is( |
243 |
is( |
243 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
244 |
C4::Circulation::TooMany( $patron, $item_object ), |
244 |
undef, |
245 |
undef, |
245 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
246 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
246 |
); |
247 |
); |
247 |
is( |
248 |
is( |
248 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
249 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
249 |
undef, |
250 |
undef, |
250 |
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
251 |
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
251 |
); |
252 |
); |
Lines 272-278
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub {
Link Here
|
272 |
|
273 |
|
273 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
274 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
274 |
is_deeply( |
275 |
is_deeply( |
275 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
276 |
C4::Circulation::TooMany( $patron, $item_object ), |
276 |
{ |
277 |
{ |
277 |
reason => 'TOO_MANY_CHECKOUTS', |
278 |
reason => 'TOO_MANY_CHECKOUTS', |
278 |
count => 1, |
279 |
count => 1, |
Lines 281-294
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub {
Link Here
|
281 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
282 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
282 |
); |
283 |
); |
283 |
is( |
284 |
is( |
284 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
285 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
285 |
undef, |
286 |
undef, |
286 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
287 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
287 |
); |
288 |
); |
288 |
|
289 |
|
289 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
290 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
290 |
is_deeply( |
291 |
is_deeply( |
291 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
292 |
C4::Circulation::TooMany( $patron, $item_object ), |
292 |
{ |
293 |
{ |
293 |
reason => 'TOO_MANY_CHECKOUTS', |
294 |
reason => 'TOO_MANY_CHECKOUTS', |
294 |
count => 1, |
295 |
count => 1, |
Lines 297-303
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub {
Link Here
|
297 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
298 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
298 |
); |
299 |
); |
299 |
is_deeply( |
300 |
is_deeply( |
300 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
301 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
301 |
{ |
302 |
{ |
302 |
reason => 'TOO_MANY_CHECKOUTS', |
303 |
reason => 'TOO_MANY_CHECKOUTS', |
303 |
count => 1, |
304 |
count => 1, |
Lines 328-339
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub {
Link Here
|
328 |
|
329 |
|
329 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
330 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
330 |
is( |
331 |
is( |
331 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
332 |
C4::Circulation::TooMany( $patron, $item_object ), |
332 |
undef, |
333 |
undef, |
333 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
334 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
334 |
); |
335 |
); |
335 |
is_deeply( |
336 |
is_deeply( |
336 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
337 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
337 |
{ |
338 |
{ |
338 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
339 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
339 |
count => 1, |
340 |
count => 1, |
Lines 344-350
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub {
Link Here
|
344 |
|
345 |
|
345 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
346 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
346 |
is_deeply( |
347 |
is_deeply( |
347 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
348 |
C4::Circulation::TooMany( $patron, $item_object ), |
348 |
{ |
349 |
{ |
349 |
reason => 'TOO_MANY_CHECKOUTS', |
350 |
reason => 'TOO_MANY_CHECKOUTS', |
350 |
count => 1, |
351 |
count => 1, |
Lines 353-359
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub {
Link Here
|
353 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
354 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
354 |
); |
355 |
); |
355 |
is_deeply( |
356 |
is_deeply( |
356 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
357 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
357 |
{ |
358 |
{ |
358 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
359 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
359 |
count => 1, |
360 |
count => 1, |
Lines 387-393
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
387 |
|
388 |
|
388 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
389 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
389 |
is_deeply( |
390 |
is_deeply( |
390 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
391 |
C4::Circulation::TooMany( $patron, $item_object ), |
391 |
{ |
392 |
{ |
392 |
reason => 'TOO_MANY_CHECKOUTS', |
393 |
reason => 'TOO_MANY_CHECKOUTS', |
393 |
count => 1, |
394 |
count => 1, |
Lines 396-409
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
396 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
397 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
397 |
); |
398 |
); |
398 |
is( |
399 |
is( |
399 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
400 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
400 |
undef, |
401 |
undef, |
401 |
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
402 |
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
402 |
); |
403 |
); |
403 |
|
404 |
|
404 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
405 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
405 |
is_deeply( |
406 |
is_deeply( |
406 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
407 |
C4::Circulation::TooMany( $patron, $item_object ), |
407 |
{ |
408 |
{ |
408 |
reason => 'TOO_MANY_CHECKOUTS', |
409 |
reason => 'TOO_MANY_CHECKOUTS', |
409 |
count => 1, |
410 |
count => 1, |
Lines 412-418
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
412 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
413 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
413 |
); |
414 |
); |
414 |
is_deeply( |
415 |
is_deeply( |
415 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
416 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
416 |
{ |
417 |
{ |
417 |
reason => 'TOO_MANY_CHECKOUTS', |
418 |
reason => 'TOO_MANY_CHECKOUTS', |
418 |
count => 1, |
419 |
count => 1, |
Lines 428-439
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
428 |
|
429 |
|
429 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
430 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
430 |
is( |
431 |
is( |
431 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
432 |
C4::Circulation::TooMany( $patron, $item_object ), |
432 |
undef, |
433 |
undef, |
433 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
434 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
434 |
); |
435 |
); |
435 |
is_deeply( |
436 |
is_deeply( |
436 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
437 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
437 |
{ |
438 |
{ |
438 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
439 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
439 |
count => 1, |
440 |
count => 1, |
Lines 444-450
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
444 |
|
445 |
|
445 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
446 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
446 |
is_deeply( |
447 |
is_deeply( |
447 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
448 |
C4::Circulation::TooMany( $patron, $item_object ), |
448 |
{ |
449 |
{ |
449 |
reason => 'TOO_MANY_CHECKOUTS', |
450 |
reason => 'TOO_MANY_CHECKOUTS', |
450 |
count => 1, |
451 |
count => 1, |
Lines 453-459
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
453 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
454 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
454 |
); |
455 |
); |
455 |
is_deeply( |
456 |
is_deeply( |
456 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
457 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
457 |
{ |
458 |
{ |
458 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
459 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
459 |
count => 1, |
460 |
count => 1, |
Lines 530-536
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
530 |
my $issue = C4::Circulation::AddIssue( $patron, $issue_item->barcode, dt_from_string() ); |
531 |
my $issue = C4::Circulation::AddIssue( $patron, $issue_item->barcode, dt_from_string() ); |
531 |
# We checkout one item |
532 |
# We checkout one item |
532 |
is_deeply( |
533 |
is_deeply( |
533 |
C4::Circulation::TooMany( $patron, $branch_item->biblionumber, $branch_item->unblessed ), |
534 |
C4::Circulation::TooMany( $patron, $branch_item ), |
534 |
{ |
535 |
{ |
535 |
reason => 'TOO_MANY_CHECKOUTS', |
536 |
reason => 'TOO_MANY_CHECKOUTS', |
536 |
count => 1, |
537 |
count => 1, |
Lines 545-551
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
545 |
$branch_item->biblio->biblioitem->itemtype($itemtype->{itemtype})->store; |
546 |
$branch_item->biblio->biblioitem->itemtype($itemtype->{itemtype})->store; |
546 |
# We checkout one item |
547 |
# We checkout one item |
547 |
is_deeply( |
548 |
is_deeply( |
548 |
C4::Circulation::TooMany( $patron, $branch_item->biblionumber, $branch_item->unblessed ), |
549 |
C4::Circulation::TooMany( $patron, $branch_item ), |
549 |
{ |
550 |
{ |
550 |
reason => 'TOO_MANY_CHECKOUTS', |
551 |
reason => 'TOO_MANY_CHECKOUTS', |
551 |
count => 1, |
552 |
count => 1, |
Lines 569-575
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
569 |
); |
570 |
); |
570 |
|
571 |
|
571 |
is( |
572 |
is( |
572 |
C4::Circulation::TooMany( $patron, $branch_item->biblionumber, $branch_item->unblessed ), |
573 |
C4::Circulation::TooMany( $patron, $branch_item ), |
573 |
undef, |
574 |
undef, |
574 |
'We are allowed one from the branch specifically now' |
575 |
'We are allowed one from the branch specifically now' |
575 |
); |
576 |
); |
Lines 577-583
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
577 |
# If circcontrol is PatronLibrary we count all the patron's loan, regardless of branch |
578 |
# If circcontrol is PatronLibrary we count all the patron's loan, regardless of branch |
578 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
579 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
579 |
is_deeply( |
580 |
is_deeply( |
580 |
C4::Circulation::TooMany( $patron, $branch_item->biblionumber, $branch_item->unblessed ), |
581 |
C4::Circulation::TooMany( $patron, $branch_item ), |
581 |
{ |
582 |
{ |
582 |
reason => 'TOO_MANY_CHECKOUTS', |
583 |
reason => 'TOO_MANY_CHECKOUTS', |
583 |
count => 1, |
584 |
count => 1, |
Lines 596-602
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
596 |
holdingbranch => $branch->{branchcode} |
597 |
holdingbranch => $branch->{branchcode} |
597 |
}); |
598 |
}); |
598 |
is_deeply( |
599 |
is_deeply( |
599 |
C4::Circulation::TooMany( $patron, $branch_item_2->biblionumber, $branch_item_2->unblessed ), |
600 |
C4::Circulation::TooMany( $patron, $branch_item_2 ), |
600 |
{ |
601 |
{ |
601 |
reason => 'TOO_MANY_CHECKOUTS', |
602 |
reason => 'TOO_MANY_CHECKOUTS', |
602 |
count => 1, |
603 |
count => 1, |
Lines 610-616
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
610 |
itype => $itemtype->{itemtype}, |
611 |
itype => $itemtype->{itemtype}, |
611 |
}); |
612 |
}); |
612 |
is_deeply( |
613 |
is_deeply( |
613 |
C4::Circulation::TooMany( $patron, $item_2->biblionumber, $item_2->unblessed ), |
614 |
C4::Circulation::TooMany( $patron, $item_2 ), |
614 |
{ |
615 |
{ |
615 |
reason => 'TOO_MANY_CHECKOUTS', |
616 |
reason => 'TOO_MANY_CHECKOUTS', |
616 |
count => 2, |
617 |
count => 2, |
Lines 620-626
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
620 |
); |
621 |
); |
621 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
622 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
622 |
is_deeply( |
623 |
is_deeply( |
623 |
C4::Circulation::TooMany( $patron, $item_2->biblionumber, $item_2->unblessed ), |
624 |
C4::Circulation::TooMany( $patron, $item_2 ), |
624 |
{ |
625 |
{ |
625 |
reason => 'TOO_MANY_CHECKOUTS', |
626 |
reason => 'TOO_MANY_CHECKOUTS', |
626 |
count => 2, |
627 |
count => 2, |
Lines 631-637
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
631 |
|
632 |
|
632 |
t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary'); |
633 |
t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary'); |
633 |
is_deeply( |
634 |
is_deeply( |
634 |
C4::Circulation::TooMany( $patron, $item_2->biblionumber, $item_2->unblessed ), |
635 |
C4::Circulation::TooMany( $patron, $item_2 ), |
635 |
{ |
636 |
{ |
636 |
reason => 'TOO_MANY_CHECKOUTS', |
637 |
reason => 'TOO_MANY_CHECKOUTS', |
637 |
count => 2, |
638 |
count => 2, |
Lines 643-649
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
643 |
my $branch2 = $builder->build({source => 'Branch',}); |
644 |
my $branch2 = $builder->build({source => 'Branch',}); |
644 |
t::lib::Mocks::mock_userenv({ branchcode => $branch2->{branchcode} }); |
645 |
t::lib::Mocks::mock_userenv({ branchcode => $branch2->{branchcode} }); |
645 |
is_deeply( |
646 |
is_deeply( |
646 |
C4::Circulation::TooMany( $patron, $item_2->biblionumber, $item_2->unblessed ), |
647 |
C4::Circulation::TooMany( $patron, $item_2 ), |
647 |
{ |
648 |
{ |
648 |
reason => 'TOO_MANY_CHECKOUTS', |
649 |
reason => 'TOO_MANY_CHECKOUTS', |
649 |
count => 2, |
650 |
count => 2, |
Lines 665-671
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
665 |
); |
666 |
); |
666 |
|
667 |
|
667 |
is( |
668 |
is( |
668 |
C4::Circulation::TooMany( $patron, $branch_item->biblionumber, $branch_item->unblessed ), |
669 |
C4::Circulation::TooMany( $patron, $branch_item ), |
669 |
undef, |
670 |
undef, |
670 |
'We are allowed one from the branch specifically now' |
671 |
'We are allowed one from the branch specifically now' |
671 |
); |
672 |
); |
Lines 686-698
subtest 'empty string means unlimited' => sub {
Link Here
|
686 |
}, |
687 |
}, |
687 |
); |
688 |
); |
688 |
is( |
689 |
is( |
689 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), |
690 |
C4::Circulation::TooMany( $patron, $item_object ), |
690 |
undef, |
691 |
undef, |
691 |
'maxissueqty="" should mean unlimited' |
692 |
'maxissueqty="" should mean unlimited' |
692 |
); |
693 |
); |
693 |
|
694 |
|
694 |
is( |
695 |
is( |
695 |
C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), |
696 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
696 |
undef, |
697 |
undef, |
697 |
'maxonsiteissueqty="" should mean unlimited' |
698 |
'maxonsiteissueqty="" should mean unlimited' |
698 |
); |
699 |
); |
699 |
- |
|
|