Lines 116-134
my $borrower = $patron->unblessed;
Link Here
|
116 |
my $biblionumber = $bibnum; |
116 |
my $biblionumber = $bibnum; |
117 |
my $barcode = $testbarcode; |
117 |
my $barcode = $testbarcode; |
118 |
|
118 |
|
119 |
my $bibitems = ''; |
|
|
120 |
my $priority = '1'; |
121 |
my $resdate = undef; |
122 |
my $expdate = undef; |
123 |
my $notes = ''; |
124 |
my $checkitem = undef; |
125 |
my $found = undef; |
126 |
|
127 |
my $branchcode = Koha::Libraries->search->next->branchcode; |
119 |
my $branchcode = Koha::Libraries->search->next->branchcode; |
128 |
|
120 |
|
129 |
AddReserve($branchcode, $borrowernumber, $biblionumber, |
121 |
AddReserve( |
130 |
$bibitems, $priority, $resdate, $expdate, $notes, |
122 |
{ |
131 |
'a title', $checkitem, $found); |
123 |
branchcode => $branchcode, |
|
|
124 |
borrowernumber => $borrowernumber, |
125 |
biblionumber => $biblionumber, |
126 |
priority => 1, |
127 |
} |
128 |
); |
132 |
|
129 |
|
133 |
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); |
130 |
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); |
134 |
|
131 |
|
Lines 251-265
my ($itemnum_cpl, $itemnum_fpl);
Link Here
|
251 |
# Ensure that priorities are numbered correcly when a hold is moved to waiting |
248 |
# Ensure that priorities are numbered correcly when a hold is moved to waiting |
252 |
# (bug 11947) |
249 |
# (bug 11947) |
253 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
250 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
254 |
AddReserve($branch_3, $requesters{$branch_3}, $bibnum2, |
251 |
AddReserve( |
255 |
$bibitems, 1, $resdate, $expdate, $notes, |
252 |
{ |
256 |
'a title', $checkitem, $found); |
253 |
branchcode => $branch_3, |
257 |
AddReserve($branch_2, $requesters{$branch_2}, $bibnum2, |
254 |
borrowernumber => $requesters{$branch_3}, |
258 |
$bibitems, 2, $resdate, $expdate, $notes, |
255 |
biblionumber => $bibnum2, |
259 |
'a title', $checkitem, $found); |
256 |
priority => 1, |
260 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum2, |
257 |
} |
261 |
$bibitems, 3, $resdate, $expdate, $notes, |
258 |
); |
262 |
'a title', $checkitem, $found); |
259 |
AddReserve( |
|
|
260 |
{ |
261 |
branchcode => $branch_2, |
262 |
borrowernumber => $requesters{$branch_2}, |
263 |
biblionumber => $bibnum2, |
264 |
priority => 2, |
265 |
} |
266 |
); |
267 |
AddReserve( |
268 |
{ |
269 |
branchcode => $branch_1, |
270 |
borrowernumber => $requesters{$branch_1}, |
271 |
biblionumber => $bibnum2, |
272 |
priority => 3, |
273 |
} |
274 |
); |
263 |
ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0); |
275 |
ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0); |
264 |
|
276 |
|
265 |
# Now it should have different priorities. |
277 |
# Now it should have different priorities. |
Lines 275-289
is( $reserves[0]->borrowernumber(), $requesters{$branch_3}, 'GetWaiting got the
Link Here
|
275 |
|
287 |
|
276 |
|
288 |
|
277 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
289 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
278 |
AddReserve($branch_3, $requesters{$branch_3}, $bibnum2, |
290 |
AddReserve( |
279 |
$bibitems, 1, $resdate, $expdate, $notes, |
291 |
{ |
280 |
'a title', $checkitem, $found); |
292 |
branchcode => $branch_3, |
281 |
AddReserve($branch_2, $requesters{$branch_2}, $bibnum2, |
293 |
borrowernumber => $requesters{$branch_3}, |
282 |
$bibitems, 2, $resdate, $expdate, $notes, |
294 |
biblionumber => $bibnum2, |
283 |
'a title', $checkitem, $found); |
295 |
priority => 1, |
284 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum2, |
296 |
} |
285 |
$bibitems, 3, $resdate, $expdate, $notes, |
297 |
); |
286 |
'a title', $checkitem, $found); |
298 |
AddReserve( |
|
|
299 |
{ |
300 |
branchcode => $branch_2, |
301 |
borrowernumber => $requesters{$branch_2}, |
302 |
biblionumber => $bibnum2, |
303 |
priority => 2, |
304 |
} |
305 |
); |
306 |
|
307 |
AddReserve( |
308 |
{ |
309 |
branchcode => $branch_1, |
310 |
borrowernumber => $requesters{$branch_1}, |
311 |
biblionumber => $bibnum2, |
312 |
priority => 3, |
313 |
} |
314 |
); |
287 |
|
315 |
|
288 |
# Ensure that the item's home library controls hold policy lookup |
316 |
# Ensure that the item's home library controls hold policy lookup |
289 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); |
317 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); |
Lines 317-328
my $reserve_id = $holds->next->reserve_id;
Link Here
|
317 |
# Tests for bug 9761 (ConfirmFutureHolds): new CheckReserves lookahead parameter, and corresponding change in AddReturn |
345 |
# Tests for bug 9761 (ConfirmFutureHolds): new CheckReserves lookahead parameter, and corresponding change in AddReturn |
318 |
# Note that CheckReserve uses its lookahead parameter and does not check ConfirmFutureHolds pref (it should be passed if needed like AddReturn does) |
346 |
# Note that CheckReserve uses its lookahead parameter and does not check ConfirmFutureHolds pref (it should be passed if needed like AddReturn does) |
319 |
# Test 9761a: Add a reserve without date, CheckReserve should return it |
347 |
# Test 9761a: Add a reserve without date, CheckReserve should return it |
320 |
$resdate= undef; #defaults to today in AddReserve |
|
|
321 |
$expdate= undef; #no expdate |
322 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
348 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
323 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
349 |
AddReserve( |
324 |
$bibitems, 1, $resdate, $expdate, $notes, |
350 |
{ |
325 |
'a title', $checkitem, $found); |
351 |
branchcode => $branch_1, |
|
|
352 |
borrowernumber => $requesters{$branch_1}, |
353 |
biblionumber => $bibnum, |
354 |
priority => 1, |
355 |
} |
356 |
); |
326 |
($status)=CheckReserves($itemnumber,undef,undef); |
357 |
($status)=CheckReserves($itemnumber,undef,undef); |
327 |
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead'); |
358 |
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead'); |
328 |
($status)=CheckReserves($itemnumber,undef,7); |
359 |
($status)=CheckReserves($itemnumber,undef,7); |
Lines 331-343
is( $status, 'Reserved', 'CheckReserves also returns reserve with lookahead');
Link Here
|
331 |
# Test 9761b: Add a reserve with future date, CheckReserve should not return it |
362 |
# Test 9761b: Add a reserve with future date, CheckReserve should not return it |
332 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
363 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
333 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
364 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
334 |
$resdate= dt_from_string(); |
365 |
my $resdate= dt_from_string(); |
335 |
$resdate->add_duration(DateTime::Duration->new(days => 4)); |
366 |
$resdate->add_duration(DateTime::Duration->new(days => 4)); |
336 |
$resdate=output_pref($resdate); |
367 |
$resdate=output_pref($resdate); |
337 |
$expdate= undef; #no expdate |
368 |
AddReserve( |
338 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
369 |
{ |
339 |
$bibitems, 1, $resdate, $expdate, $notes, |
370 |
branchcode => $branch_1, |
340 |
'a title', $checkitem, $found); |
371 |
borrowernumber => $requesters{$branch_1}, |
|
|
372 |
biblionumber => $bibnum, |
373 |
priority => 1, |
374 |
reservation_date => $resdate, |
375 |
} |
376 |
); |
341 |
($status)=CheckReserves($itemnumber,undef,undef); |
377 |
($status)=CheckReserves($itemnumber,undef,undef); |
342 |
is( $status, '', 'CheckReserves returns no future reserve without lookahead'); |
378 |
is( $status, '', 'CheckReserves returns no future reserve without lookahead'); |
343 |
|
379 |
|
Lines 392-400
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
Link Here
|
392 |
$resdate= dt_from_string(); |
428 |
$resdate= dt_from_string(); |
393 |
$resdate->add_duration(DateTime::Duration->new(days => 2)); |
429 |
$resdate->add_duration(DateTime::Duration->new(days => 2)); |
394 |
$resdate=output_pref($resdate); |
430 |
$resdate=output_pref($resdate); |
395 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
431 |
AddReserve( |
396 |
$bibitems, 1, $resdate, $expdate, $notes, |
432 |
{ |
397 |
'a title', $checkitem, $found); |
433 |
branchcode => $branch_1, |
|
|
434 |
borrowernumber => $requesters{$branch_1}, |
435 |
biblionumber => $bibnum, |
436 |
priority => 1, |
437 |
reservation_date => $resdate, |
438 |
} |
439 |
); |
440 |
|
398 |
my $item = Koha::Items->find( $itemnumber ); |
441 |
my $item = Koha::Items->find( $itemnumber ); |
399 |
$holds = $item->current_holds; |
442 |
$holds = $item->current_holds; |
400 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
443 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
Lines 402-410
my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( d
Link Here
|
402 |
is( $future_holds->count, 0, 'current_holds does not return a future next available hold'); |
445 |
is( $future_holds->count, 0, 'current_holds does not return a future next available hold'); |
403 |
# 9788b: current_holds does not return future item level hold |
446 |
# 9788b: current_holds does not return future item level hold |
404 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
447 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
405 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
448 |
AddReserve( |
406 |
$bibitems, 1, $resdate, $expdate, $notes, |
449 |
{ |
407 |
'a title', $itemnumber, $found); #item level hold |
450 |
branchcode => $branch_1, |
|
|
451 |
borrowernumber => $requesters{$branch_1}, |
452 |
biblionumber => $bibnum, |
453 |
priority => 1, |
454 |
reservation_date => $resdate, |
455 |
itemnumber => $itemnumber, |
456 |
} |
457 |
); #item level hold |
408 |
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); |
458 |
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); |
409 |
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); |
459 |
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); |
410 |
# 9788c: current_holds returns future wait (confirmed future hold) |
460 |
# 9788c: current_holds returns future wait (confirmed future hold) |
Lines 417-426
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
Link Here
|
417 |
# Tests for CalculatePriority (bug 8918) |
467 |
# Tests for CalculatePriority (bug 8918) |
418 |
my $p = C4::Reserves::CalculatePriority($bibnum2); |
468 |
my $p = C4::Reserves::CalculatePriority($bibnum2); |
419 |
is($p, 4, 'CalculatePriority should now return priority 4'); |
469 |
is($p, 4, 'CalculatePriority should now return priority 4'); |
420 |
$resdate=undef; |
470 |
AddReserve( |
421 |
AddReserve($branch_1, $requesters{'CPL2'}, $bibnum2, |
471 |
{ |
422 |
$bibitems, $p, $resdate, $expdate, $notes, |
472 |
branchcode => $branch_1, |
423 |
'a title', $checkitem, $found); |
473 |
borrowernumber => $requesters{'CPL2'}, |
|
|
474 |
biblionumber => $bibnum2, |
475 |
priority => $p, |
476 |
} |
477 |
); |
424 |
$p = C4::Reserves::CalculatePriority($bibnum2); |
478 |
$p = C4::Reserves::CalculatePriority($bibnum2); |
425 |
is($p, 5, 'CalculatePriority should now return priority 5'); |
479 |
is($p, 5, 'CalculatePriority should now return priority 5'); |
426 |
#some tests on bibnum |
480 |
#some tests on bibnum |
Lines 428-454
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
Link Here
|
428 |
$p = C4::Reserves::CalculatePriority($bibnum); |
482 |
$p = C4::Reserves::CalculatePriority($bibnum); |
429 |
is($p, 1, 'CalculatePriority should now return priority 1'); |
483 |
is($p, 1, 'CalculatePriority should now return priority 1'); |
430 |
#add a new reserve and confirm it to waiting |
484 |
#add a new reserve and confirm it to waiting |
431 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
485 |
AddReserve( |
432 |
$bibitems, $p, $resdate, $expdate, $notes, |
486 |
{ |
433 |
'a title', $itemnumber, $found); |
487 |
branchcode => $branch_1, |
|
|
488 |
borrowernumber => $requesters{$branch_1}, |
489 |
biblionumber => $bibnum, |
490 |
priority => $p, |
491 |
itemnumber => $itemnumber, |
492 |
} |
493 |
); |
434 |
$p = C4::Reserves::CalculatePriority($bibnum); |
494 |
$p = C4::Reserves::CalculatePriority($bibnum); |
435 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
495 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
436 |
ModReserveAffect( $itemnumber, $requesters{$branch_1} , 0); |
496 |
ModReserveAffect( $itemnumber, $requesters{$branch_1} , 0); |
437 |
$p = C4::Reserves::CalculatePriority($bibnum); |
497 |
$p = C4::Reserves::CalculatePriority($bibnum); |
438 |
is($p, 1, 'CalculatePriority should now return priority 1'); |
498 |
is($p, 1, 'CalculatePriority should now return priority 1'); |
439 |
#add another biblio hold, no resdate |
499 |
#add another biblio hold, no resdate |
440 |
AddReserve($branch_1, $requesters{'CPL2'}, $bibnum, |
500 |
AddReserve( |
441 |
$bibitems, $p, $resdate, $expdate, $notes, |
501 |
{ |
442 |
'a title', $checkitem, $found); |
502 |
branchcode => $branch_1, |
|
|
503 |
borrowernumber => $requesters{'CPL2'}, |
504 |
biblionumber => $bibnum, |
505 |
priority => $p, |
506 |
} |
507 |
); |
443 |
$p = C4::Reserves::CalculatePriority($bibnum); |
508 |
$p = C4::Reserves::CalculatePriority($bibnum); |
444 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
509 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
445 |
#add another future hold |
510 |
#add another future hold |
446 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
511 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
447 |
$resdate= dt_from_string(); |
512 |
$resdate= dt_from_string(); |
448 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
513 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
449 |
AddReserve($branch_1, $requesters{'CPL3'}, $bibnum, |
514 |
AddReserve( |
450 |
$bibitems, $p, output_pref($resdate), $expdate, $notes, |
515 |
{ |
451 |
'a title', $checkitem, $found); |
516 |
branchcode => $branch_1, |
|
|
517 |
borrowernumber => $requesters{'CPL2'}, |
518 |
biblionumber => $bibnum, |
519 |
priority => $p, |
520 |
reservation_date => output_pref($resdate), |
521 |
} |
522 |
); |
452 |
$p = C4::Reserves::CalculatePriority($bibnum); |
523 |
$p = C4::Reserves::CalculatePriority($bibnum); |
453 |
is($p, 2, 'CalculatePriority should now still return priority 2'); |
524 |
is($p, 2, 'CalculatePriority should now still return priority 2'); |
454 |
#calc priority with future resdate |
525 |
#calc priority with future resdate |
Lines 458-466
is($p, 3, 'CalculatePriority should now return priority 3');
Link Here
|
458 |
|
529 |
|
459 |
# Tests for cancel reserves by users from OPAC. |
530 |
# Tests for cancel reserves by users from OPAC. |
460 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
531 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
461 |
AddReserve($branch_1, $requesters{$branch_1}, $item_bibnum, |
532 |
AddReserve( |
462 |
$bibitems, 1, undef, $expdate, $notes, |
533 |
{ |
463 |
'a title', $checkitem, ''); |
534 |
branchcode => $branch_1, |
|
|
535 |
borrowernumber => $requesters{$branch_1}, |
536 |
biblionumber => $item_bibnum, |
537 |
priority => 1, |
538 |
} |
539 |
); |
464 |
my (undef, $canres, undef) = CheckReserves($itemnumber); |
540 |
my (undef, $canres, undef) = CheckReserves($itemnumber); |
465 |
|
541 |
|
466 |
is( CanReserveBeCanceledFromOpac(), undef, |
542 |
is( CanReserveBeCanceledFromOpac(), undef, |
Lines 488-496
$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$br
Link Here
|
488 |
is($cancancel, 0, 'Reserve in transfer status cant be canceled'); |
564 |
is($cancancel, 0, 'Reserve in transfer status cant be canceled'); |
489 |
|
565 |
|
490 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
566 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
491 |
AddReserve($branch_1, $requesters{$branch_1}, $item_bibnum, |
567 |
AddReserve( |
492 |
$bibitems, 1, undef, $expdate, $notes, |
568 |
{ |
493 |
'a title', $checkitem, ''); |
569 |
branchcode => $branch_1, |
|
|
570 |
borrowernumber => $requesters{$branch_1}, |
571 |
biblionumber => $item_bibnum, |
572 |
priority => 1, |
573 |
} |
574 |
); |
494 |
(undef, $canres, undef) = CheckReserves($itemnumber); |
575 |
(undef, $canres, undef) = CheckReserves($itemnumber); |
495 |
|
576 |
|
496 |
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0); |
577 |
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0); |
Lines 568-581
Koha::CirculationRules->set_rules(
Link Here
|
568 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
649 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
569 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0); |
650 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0); |
570 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
651 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
571 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
652 |
AddReserve( |
572 |
$bibitems, 1, undef, $expdate, $notes, 'a title', $checkitem, ''); |
653 |
{ |
|
|
654 |
branchcode => $branch_1, |
655 |
borrowernumber => $borrowernumber, |
656 |
biblionumber => $item_bibnum, |
657 |
priority => 1, |
658 |
} |
659 |
); |
573 |
MoveReserve( $itemnumber, $borrowernumber ); |
660 |
MoveReserve( $itemnumber, $borrowernumber ); |
574 |
($status)=CheckReserves( $itemnumber ); |
661 |
($status)=CheckReserves( $itemnumber ); |
575 |
is( $status, '', 'MoveReserve filled hold'); |
662 |
is( $status, '', 'MoveReserve filled hold'); |
576 |
# hold from A waiting, today, no fut holds: MoveReserve should fill it |
663 |
# hold from A waiting, today, no fut holds: MoveReserve should fill it |
577 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
664 |
AddReserve( |
578 |
$bibitems, 1, undef, $expdate, $notes, 'a title', $checkitem, 'W'); |
665 |
{ |
|
|
666 |
branchcode => $branch_1, |
667 |
borrowernumber => $borrowernumber, |
668 |
biblionumber => $item_bibnum, |
669 |
priority => 1, |
670 |
found => 'W', |
671 |
} |
672 |
); |
579 |
MoveReserve( $itemnumber, $borrowernumber ); |
673 |
MoveReserve( $itemnumber, $borrowernumber ); |
580 |
($status)=CheckReserves( $itemnumber ); |
674 |
($status)=CheckReserves( $itemnumber ); |
581 |
is( $status, '', 'MoveReserve filled waiting hold'); |
675 |
is( $status, '', 'MoveReserve filled waiting hold'); |
Lines 583-604
is( $status, '', 'MoveReserve filled waiting hold');
Link Here
|
583 |
$resdate= dt_from_string(); |
677 |
$resdate= dt_from_string(); |
584 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
678 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
585 |
$resdate=output_pref($resdate); |
679 |
$resdate=output_pref($resdate); |
586 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
680 |
AddReserve( |
587 |
$bibitems, 1, $resdate, $expdate, $notes, 'a title', $checkitem, ''); |
681 |
{ |
|
|
682 |
branchcode => $branch_1, |
683 |
borrowernumber => $borrowernumber, |
684 |
biblionumber => $item_bibnum, |
685 |
priority => 1, |
686 |
reservation_date => $resdate, |
687 |
} |
688 |
); |
588 |
MoveReserve( $itemnumber, $borrowernumber ); |
689 |
MoveReserve( $itemnumber, $borrowernumber ); |
589 |
($status)=CheckReserves( $itemnumber, undef, 1 ); |
690 |
($status)=CheckReserves( $itemnumber, undef, 1 ); |
590 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold'); |
691 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold'); |
591 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
692 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
592 |
# hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it |
693 |
# hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it |
593 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2); |
694 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2); |
594 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
695 |
AddReserve( |
595 |
$bibitems, 1, $resdate, $expdate, $notes, 'a title', $checkitem, ''); |
696 |
{ |
|
|
697 |
branchcode => $branch_1, |
698 |
borrowernumber => $borrowernumber, |
699 |
biblionumber => $item_bibnum, |
700 |
priority => 1, |
701 |
reservation_date => $resdate, |
702 |
} |
703 |
); |
596 |
MoveReserve( $itemnumber, $borrowernumber ); |
704 |
MoveReserve( $itemnumber, $borrowernumber ); |
597 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
705 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
598 |
is( $status, '', 'MoveReserve filled future hold now'); |
706 |
is( $status, '', 'MoveReserve filled future hold now'); |
599 |
# hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it |
707 |
# hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it |
600 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
708 |
AddReserve( |
601 |
$bibitems, 1, $resdate, $expdate, $notes, 'a title', $checkitem, 'W'); |
709 |
{ |
|
|
710 |
branchcode => $branch_1, |
711 |
borrowernumber => $borrowernumber, |
712 |
biblionumber => $item_bibnum, |
713 |
priority => 1, |
714 |
reservation_date => $resdate, |
715 |
} |
716 |
); |
602 |
MoveReserve( $itemnumber, $borrowernumber ); |
717 |
MoveReserve( $itemnumber, $borrowernumber ); |
603 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
718 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
604 |
is( $status, '', 'MoveReserve filled future waiting hold now'); |
719 |
is( $status, '', 'MoveReserve filled future waiting hold now'); |
Lines 606-613
is( $status, '', 'MoveReserve filled future waiting hold now');
Link Here
|
606 |
$resdate= dt_from_string(); |
721 |
$resdate= dt_from_string(); |
607 |
$resdate->add_duration(DateTime::Duration->new(days => 3)); |
722 |
$resdate->add_duration(DateTime::Duration->new(days => 3)); |
608 |
$resdate=output_pref($resdate); |
723 |
$resdate=output_pref($resdate); |
609 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
724 |
AddReserve( |
610 |
$bibitems, 1, $resdate, $expdate, $notes, 'a title', $checkitem, ''); |
725 |
{ |
|
|
726 |
branchcode => $branch_1, |
727 |
borrowernumber => $borrowernumber, |
728 |
biblionumber => $item_bibnum, |
729 |
priority => 1, |
730 |
reservation_date => $resdate, |
731 |
} |
732 |
); |
611 |
MoveReserve( $itemnumber, $borrowernumber ); |
733 |
MoveReserve( $itemnumber, $borrowernumber ); |
612 |
($status)=CheckReserves( $itemnumber, undef, 3 ); |
734 |
($status)=CheckReserves( $itemnumber, undef, 3 ); |
613 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
735 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
Lines 668-675
subtest '_koha_notify_reserve() tests' => sub {
Link Here
|
668 |
})->{borrowernumber}; |
790 |
})->{borrowernumber}; |
669 |
|
791 |
|
670 |
C4::Reserves::AddReserve( |
792 |
C4::Reserves::AddReserve( |
671 |
$item->homebranch, $hold_borrower, |
793 |
{ |
672 |
$item->biblionumber ); |
794 |
branchcode => $item->homebranch, |
|
|
795 |
borrowernumber => $hold_borrower, |
796 |
biblionumber => $item->biblionumber, |
797 |
} |
798 |
); |
673 |
|
799 |
|
674 |
ModReserveAffect($item->itemnumber, $hold_borrower, 0); |
800 |
ModReserveAffect($item->itemnumber, $hold_borrower, 0); |
675 |
my $sms_message_address = $schema->resultset('MessageQueue')->search({ |
801 |
my $sms_message_address = $schema->resultset('MessageQueue')->search({ |
Lines 817-826
subtest 'reserves.item_level_hold' => sub {
Link Here
|
817 |
|
943 |
|
818 |
subtest 'item level hold' => sub { |
944 |
subtest 'item level hold' => sub { |
819 |
plan tests => 2; |
945 |
plan tests => 2; |
820 |
my $reserve_id = |
946 |
my $reserve_id = AddReserve( |
821 |
AddReserve( $item->homebranch, $patron->borrowernumber, |
947 |
{ |
822 |
$item->biblionumber, undef, 1, undef, undef, '', '', |
948 |
branchcode => $item->homebranch, |
823 |
$item->itemnumber ); |
949 |
borrowernumber => $patron->borrowernumber, |
|
|
950 |
biblionumber => $item->biblionumber, |
951 |
priority => 1, |
952 |
itemnumber => $item->itemnumber, |
953 |
} |
954 |
); |
824 |
|
955 |
|
825 |
my $hold = Koha::Holds->find($reserve_id); |
956 |
my $hold = Koha::Holds->find($reserve_id); |
826 |
is( $hold->item_level_hold, 1, 'item_level_hold should be set when AddReserve is called with a specific item' ); |
957 |
is( $hold->item_level_hold, 1, 'item_level_hold should be set when AddReserve is called with a specific item' ); |
Lines 841-848
subtest 'reserves.item_level_hold' => sub {
Link Here
|
841 |
|
972 |
|
842 |
subtest 'biblio level hold' => sub { |
973 |
subtest 'biblio level hold' => sub { |
843 |
plan tests => 3; |
974 |
plan tests => 3; |
844 |
my $reserve_id = AddReserve( $item->homebranch, $patron->borrowernumber, |
975 |
my $reserve_id = AddReserve( |
845 |
$item->biblionumber, undef, 1 ); |
976 |
{ |
|
|
977 |
branchcode => $item->homebranch, |
978 |
borrowernumber => $patron->borrowernumber, |
979 |
biblionumber => $item->biblionumber, |
980 |
priority => 1, |
981 |
} |
982 |
); |
846 |
|
983 |
|
847 |
my $hold = Koha::Holds->find($reserve_id); |
984 |
my $hold = Koha::Holds->find($reserve_id); |
848 |
is( $hold->item_level_hold, 0, 'item_level_hold should not be set when AddReserve is called without a specific item' ); |
985 |
is( $hold->item_level_hold, 0, 'item_level_hold should not be set when AddReserve is called without a specific item' ); |
Lines 877-884
subtest 'MoveReserve additional test' => sub {
Link Here
|
877 |
my $patron_2 = $builder->build_object({ class => "Koha::Patrons" }); |
1014 |
my $patron_2 = $builder->build_object({ class => "Koha::Patrons" }); |
878 |
|
1015 |
|
879 |
# Place a hold on the title for both patrons |
1016 |
# Place a hold on the title for both patrons |
880 |
my $reserve_1 = AddReserve( $item_1->homebranch, $patron_1->borrowernumber, $biblio->biblionumber, undef, 1 ); |
1017 |
my $reserve_1 = AddReserve( |
881 |
my $reserve_2 = AddReserve( $item_2->homebranch, $patron_2->borrowernumber, $biblio->biblionumber, undef, 1 ); |
1018 |
{ |
|
|
1019 |
branchcode => $item_1->homebranch, |
1020 |
borrowernumber => $patron_1->borrowernumber, |
1021 |
biblionumber => $biblio->biblionumber, |
1022 |
priority => 1, |
1023 |
itemnumber => $item_1->itemnumber, |
1024 |
} |
1025 |
); |
1026 |
my $reserve_2 = AddReserve( |
1027 |
{ |
1028 |
branchcode => $item_2->homebranch, |
1029 |
borrowernumber => $patron_2->borrowernumber, |
1030 |
biblionumber => $biblio->biblionumber, |
1031 |
priority => 1, |
1032 |
itemnumber => $item_1->itemnumber, |
1033 |
} |
1034 |
); |
882 |
is($patron_1->holds->next()->reserve_id, $reserve_1, "The 1st patron has a hold"); |
1035 |
is($patron_1->holds->next()->reserve_id, $reserve_1, "The 1st patron has a hold"); |
883 |
is($patron_2->holds->next()->reserve_id, $reserve_2, "The 2nd patron has a hold"); |
1036 |
is($patron_2->holds->next()->reserve_id, $reserve_2, "The 2nd patron has a hold"); |
884 |
|
1037 |
|
Lines 906-917
sub place_item_hold {
Link Here
|
906 |
my ($patron,$item,$library,$priority) = @_; |
1059 |
my ($patron,$item,$library,$priority) = @_; |
907 |
|
1060 |
|
908 |
my $hold_id = C4::Reserves::AddReserve( |
1061 |
my $hold_id = C4::Reserves::AddReserve( |
909 |
$library->branchcode, $patron->borrowernumber, |
1062 |
{ |
910 |
$item->biblionumber, '', |
1063 |
branchcode => $library->branchcode, |
911 |
$priority, undef, |
1064 |
borrowernumber => $patron->borrowernumber, |
912 |
undef, '', |
1065 |
biblionumber => $item->biblionumber, |
913 |
"title for fee", $item->itemnumber, |
1066 |
priority => $priority, |
|
|
1067 |
title => "title for fee", |
1068 |
itemnumber => $item->itemnumber, |
1069 |
} |
914 |
); |
1070 |
); |
|
|
1071 |
|
915 |
my $hold = Koha::Holds->find($hold_id); |
1072 |
my $hold = Koha::Holds->find($hold_id); |
916 |
return $hold; |
1073 |
return $hold; |
917 |
} |
1074 |
} |