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