Lines 65-87
my $patron = $builder->build({
Link Here
|
65 |
}, |
65 |
}, |
66 |
}); |
66 |
}); |
67 |
|
67 |
|
68 |
my $biblio = $builder->build({ |
68 |
my $biblio = $builder->build_sample_biblio({ branchcode => $branch->{branchcode} }); |
69 |
source => 'Biblio', |
69 |
my $item = $builder->build_sample_item({ |
70 |
value => { |
70 |
biblionumber => $biblio->biblionumber, |
71 |
branchcode => $branch->{branchcode}, |
71 |
homebranch => $branch->{branchcode}, |
72 |
}, |
72 |
holdingbranch => $branch->{branchcode}, |
73 |
}); |
|
|
74 |
my $item = $builder->build({ |
75 |
source => 'Item', |
76 |
value => { |
77 |
biblionumber => $biblio->{biblionumber}, |
78 |
homebranch => $branch->{branchcode}, |
79 |
holdingbranch => $branch->{branchcode}, |
80 |
}, |
81 |
}); |
73 |
}); |
82 |
|
74 |
|
83 |
my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); |
75 |
my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); |
84 |
my $item_object = Koha::Items->find( $item->{itemnumber} ); |
|
|
85 |
t::lib::Mocks::mock_userenv( { patron => $patron_object }); |
76 |
t::lib::Mocks::mock_userenv( { patron => $patron_object }); |
86 |
|
77 |
|
87 |
# TooMany return ($current_loan_count, $max_loans_allowed) or undef |
78 |
# TooMany return ($current_loan_count, $max_loans_allowed) or undef |
Lines 91-102
t::lib::Mocks::mock_userenv( { patron => $patron_object });
Link Here
|
91 |
subtest 'no rules exist' => sub { |
82 |
subtest 'no rules exist' => sub { |
92 |
plan tests => 2; |
83 |
plan tests => 2; |
93 |
is_deeply( |
84 |
is_deeply( |
94 |
C4::Circulation::TooMany( $patron, $item_object ), |
85 |
C4::Circulation::TooMany( $patron, $item ), |
95 |
{ reason => 'NO_RULE_DEFINED', max_allowed => 0 }, |
86 |
{ reason => 'NO_RULE_DEFINED', max_allowed => 0 }, |
96 |
'CO should not be allowed, in any cases' |
87 |
'CO should not be allowed, in any cases' |
97 |
); |
88 |
); |
98 |
is_deeply( |
89 |
is_deeply( |
99 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
90 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
100 |
{ reason => 'NO_RULE_DEFINED', max_allowed => 0 }, |
91 |
{ reason => 'NO_RULE_DEFINED', max_allowed => 0 }, |
101 |
'OSCO should not be allowed, in any cases' |
92 |
'OSCO should not be allowed, in any cases' |
102 |
); |
93 |
); |
Lines 117-123
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
117 |
); |
108 |
); |
118 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
109 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
119 |
is_deeply( |
110 |
is_deeply( |
120 |
C4::Circulation::TooMany( $patron, $item_object ), |
111 |
C4::Circulation::TooMany( $patron, $item ), |
121 |
{ |
112 |
{ |
122 |
reason => 'TOO_MANY_CHECKOUTS', |
113 |
reason => 'TOO_MANY_CHECKOUTS', |
123 |
count => 0, |
114 |
count => 0, |
Lines 126-132
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
126 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
117 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
127 |
); |
118 |
); |
128 |
is_deeply( |
119 |
is_deeply( |
129 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
120 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
130 |
{ |
121 |
{ |
131 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
122 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
132 |
count => 0, |
123 |
count => 0, |
Lines 137-143
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
137 |
|
128 |
|
138 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
129 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
139 |
is_deeply( |
130 |
is_deeply( |
140 |
C4::Circulation::TooMany( $patron, $item_object ), |
131 |
C4::Circulation::TooMany( $patron, $item ), |
141 |
{ |
132 |
{ |
142 |
reason => 'TOO_MANY_CHECKOUTS', |
133 |
reason => 'TOO_MANY_CHECKOUTS', |
143 |
count => 0, |
134 |
count => 0, |
Lines 146-152
subtest '1 Issuingrule exist 0 0: no issue allowed' => sub {
Link Here
|
146 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
137 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
147 |
); |
138 |
); |
148 |
is_deeply( |
139 |
is_deeply( |
149 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
140 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
150 |
{ |
141 |
{ |
151 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
142 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
152 |
count => 0, |
143 |
count => 0, |
Lines 173-182
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub {
Link Here
|
173 |
}, |
164 |
}, |
174 |
); |
165 |
); |
175 |
|
166 |
|
176 |
my $issue = C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string() ); |
167 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string() ); |
177 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
168 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
178 |
is_deeply( |
169 |
is_deeply( |
179 |
C4::Circulation::TooMany( $patron, $item_object ), |
170 |
C4::Circulation::TooMany( $patron, $item ), |
180 |
{ |
171 |
{ |
181 |
reason => 'TOO_MANY_CHECKOUTS', |
172 |
reason => 'TOO_MANY_CHECKOUTS', |
182 |
count => 1, |
173 |
count => 1, |
Lines 185-198
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub {
Link Here
|
185 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
176 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
186 |
); |
177 |
); |
187 |
is( |
178 |
is( |
188 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
179 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
189 |
undef, |
180 |
undef, |
190 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
181 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
191 |
); |
182 |
); |
192 |
|
183 |
|
193 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
184 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
194 |
is_deeply( |
185 |
is_deeply( |
195 |
C4::Circulation::TooMany( $patron, $item_object ), |
186 |
C4::Circulation::TooMany( $patron, $item ), |
196 |
{ |
187 |
{ |
197 |
reason => 'TOO_MANY_CHECKOUTS', |
188 |
reason => 'TOO_MANY_CHECKOUTS', |
198 |
count => 1, |
189 |
count => 1, |
Lines 201-207
subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub {
Link Here
|
201 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
192 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
202 |
); |
193 |
); |
203 |
is_deeply( |
194 |
is_deeply( |
204 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
195 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
205 |
{ |
196 |
{ |
206 |
reason => 'TOO_MANY_CHECKOUTS', |
197 |
reason => 'TOO_MANY_CHECKOUTS', |
207 |
count => 1, |
198 |
count => 1, |
Lines 229-252
subtest '1 Issuingrule exist 1 1: issue is allowed' => sub {
Link Here
|
229 |
); |
220 |
); |
230 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
221 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
231 |
is( |
222 |
is( |
232 |
C4::Circulation::TooMany( $patron, $item_object ), |
223 |
C4::Circulation::TooMany( $patron, $item ), |
233 |
undef, |
224 |
undef, |
234 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
225 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
235 |
); |
226 |
); |
236 |
is( |
227 |
is( |
237 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
228 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
238 |
undef, |
229 |
undef, |
239 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
230 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
240 |
); |
231 |
); |
241 |
|
232 |
|
242 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
233 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
243 |
is( |
234 |
is( |
244 |
C4::Circulation::TooMany( $patron, $item_object ), |
235 |
C4::Circulation::TooMany( $patron, $item ), |
245 |
undef, |
236 |
undef, |
246 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
237 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
247 |
); |
238 |
); |
248 |
is( |
239 |
is( |
249 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
240 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
250 |
undef, |
241 |
undef, |
251 |
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
242 |
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
252 |
); |
243 |
); |
Lines 268-279
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub {
Link Here
|
268 |
} |
259 |
} |
269 |
); |
260 |
); |
270 |
|
261 |
|
271 |
my $issue = C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string() ); |
262 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string() ); |
272 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
263 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
273 |
|
264 |
|
274 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
265 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
275 |
is_deeply( |
266 |
is_deeply( |
276 |
C4::Circulation::TooMany( $patron, $item_object ), |
267 |
C4::Circulation::TooMany( $patron, $item ), |
277 |
{ |
268 |
{ |
278 |
reason => 'TOO_MANY_CHECKOUTS', |
269 |
reason => 'TOO_MANY_CHECKOUTS', |
279 |
count => 1, |
270 |
count => 1, |
Lines 282-295
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub {
Link Here
|
282 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
273 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
283 |
); |
274 |
); |
284 |
is( |
275 |
is( |
285 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
276 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
286 |
undef, |
277 |
undef, |
287 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
278 |
'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
288 |
); |
279 |
); |
289 |
|
280 |
|
290 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
281 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
291 |
is_deeply( |
282 |
is_deeply( |
292 |
C4::Circulation::TooMany( $patron, $item_object ), |
283 |
C4::Circulation::TooMany( $patron, $item ), |
293 |
{ |
284 |
{ |
294 |
reason => 'TOO_MANY_CHECKOUTS', |
285 |
reason => 'TOO_MANY_CHECKOUTS', |
295 |
count => 1, |
286 |
count => 1, |
Lines 298-304
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub {
Link Here
|
298 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
289 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
299 |
); |
290 |
); |
300 |
is_deeply( |
291 |
is_deeply( |
301 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
292 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
302 |
{ |
293 |
{ |
303 |
reason => 'TOO_MANY_CHECKOUTS', |
294 |
reason => 'TOO_MANY_CHECKOUTS', |
304 |
count => 1, |
295 |
count => 1, |
Lines 324-340
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub {
Link Here
|
324 |
} |
315 |
} |
325 |
); |
316 |
); |
326 |
|
317 |
|
327 |
my $issue = C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string(), undef, undef, undef, { onsite_checkout => 1 } ); |
318 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string(), undef, undef, undef, { onsite_checkout => 1 } ); |
328 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
319 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
329 |
|
320 |
|
330 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
321 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
331 |
is( |
322 |
is( |
332 |
C4::Circulation::TooMany( $patron, $item_object ), |
323 |
C4::Circulation::TooMany( $patron, $item ), |
333 |
undef, |
324 |
undef, |
334 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
325 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
335 |
); |
326 |
); |
336 |
is_deeply( |
327 |
is_deeply( |
337 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
328 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
338 |
{ |
329 |
{ |
339 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
330 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
340 |
count => 1, |
331 |
count => 1, |
Lines 345-351
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub {
Link Here
|
345 |
|
336 |
|
346 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
337 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
347 |
is_deeply( |
338 |
is_deeply( |
348 |
C4::Circulation::TooMany( $patron, $item_object ), |
339 |
C4::Circulation::TooMany( $patron, $item ), |
349 |
{ |
340 |
{ |
350 |
reason => 'TOO_MANY_CHECKOUTS', |
341 |
reason => 'TOO_MANY_CHECKOUTS', |
351 |
count => 1, |
342 |
count => 1, |
Lines 354-360
subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub {
Link Here
|
354 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
345 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
355 |
); |
346 |
); |
356 |
is_deeply( |
347 |
is_deeply( |
357 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
348 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
358 |
{ |
349 |
{ |
359 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
350 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
360 |
count => 1, |
351 |
count => 1, |
Lines 383-394
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
383 |
} |
374 |
} |
384 |
); |
375 |
); |
385 |
|
376 |
|
386 |
my $issue = C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string(), undef, undef, undef ); |
377 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string(), undef, undef, undef ); |
387 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
378 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
388 |
|
379 |
|
389 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
380 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
390 |
is_deeply( |
381 |
is_deeply( |
391 |
C4::Circulation::TooMany( $patron, $item_object ), |
382 |
C4::Circulation::TooMany( $patron, $item ), |
392 |
{ |
383 |
{ |
393 |
reason => 'TOO_MANY_CHECKOUTS', |
384 |
reason => 'TOO_MANY_CHECKOUTS', |
394 |
count => 1, |
385 |
count => 1, |
Lines 397-410
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
397 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
388 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
398 |
); |
389 |
); |
399 |
is( |
390 |
is( |
400 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
391 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
401 |
undef, |
392 |
undef, |
402 |
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
393 |
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
403 |
); |
394 |
); |
404 |
|
395 |
|
405 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
396 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
406 |
is_deeply( |
397 |
is_deeply( |
407 |
C4::Circulation::TooMany( $patron, $item_object ), |
398 |
C4::Circulation::TooMany( $patron, $item ), |
408 |
{ |
399 |
{ |
409 |
reason => 'TOO_MANY_CHECKOUTS', |
400 |
reason => 'TOO_MANY_CHECKOUTS', |
410 |
count => 1, |
401 |
count => 1, |
Lines 413-419
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
413 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
404 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
414 |
); |
405 |
); |
415 |
is_deeply( |
406 |
is_deeply( |
416 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
407 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
417 |
{ |
408 |
{ |
418 |
reason => 'TOO_MANY_CHECKOUTS', |
409 |
reason => 'TOO_MANY_CHECKOUTS', |
419 |
count => 1, |
410 |
count => 1, |
Lines 424-440
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
424 |
|
415 |
|
425 |
teardown(); |
416 |
teardown(); |
426 |
|
417 |
|
427 |
$issue = C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string(), undef, undef, undef, { onsite_checkout => 1 } ); |
418 |
$issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string(), undef, undef, undef, { onsite_checkout => 1 } ); |
428 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
419 |
like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); |
429 |
|
420 |
|
430 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
421 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); |
431 |
is( |
422 |
is( |
432 |
C4::Circulation::TooMany( $patron, $item_object ), |
423 |
C4::Circulation::TooMany( $patron, $item ), |
433 |
undef, |
424 |
undef, |
434 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
425 |
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' |
435 |
); |
426 |
); |
436 |
is_deeply( |
427 |
is_deeply( |
437 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
428 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
438 |
{ |
429 |
{ |
439 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
430 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
440 |
count => 1, |
431 |
count => 1, |
Lines 445-451
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
445 |
|
436 |
|
446 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
437 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
447 |
is_deeply( |
438 |
is_deeply( |
448 |
C4::Circulation::TooMany( $patron, $item_object ), |
439 |
C4::Circulation::TooMany( $patron, $item ), |
449 |
{ |
440 |
{ |
450 |
reason => 'TOO_MANY_CHECKOUTS', |
441 |
reason => 'TOO_MANY_CHECKOUTS', |
451 |
count => 1, |
442 |
count => 1, |
Lines 454-460
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
454 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
445 |
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' |
455 |
); |
446 |
); |
456 |
is_deeply( |
447 |
is_deeply( |
457 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
448 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
458 |
{ |
449 |
{ |
459 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
450 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
460 |
count => 1, |
451 |
count => 1, |
Lines 687-699
subtest 'empty string means unlimited' => sub {
Link Here
|
687 |
}, |
678 |
}, |
688 |
); |
679 |
); |
689 |
is( |
680 |
is( |
690 |
C4::Circulation::TooMany( $patron, $item_object ), |
681 |
C4::Circulation::TooMany( $patron, $item ), |
691 |
undef, |
682 |
undef, |
692 |
'maxissueqty="" should mean unlimited' |
683 |
'maxissueqty="" should mean unlimited' |
693 |
); |
684 |
); |
694 |
|
685 |
|
695 |
is( |
686 |
is( |
696 |
C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ), |
687 |
C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ), |
697 |
undef, |
688 |
undef, |
698 |
'maxonsiteissueqty="" should mean unlimited' |
689 |
'maxonsiteissueqty="" should mean unlimited' |
699 |
); |
690 |
); |
700 |
- |
|
|