Lines 125-143
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
Link Here
|
125 |
my $biblionumber = $bibnum; |
125 |
my $biblionumber = $bibnum; |
126 |
my $barcode = $testbarcode; |
126 |
my $barcode = $testbarcode; |
127 |
|
127 |
|
128 |
my $bibitems = ''; |
|
|
129 |
my $priority = '1'; |
130 |
my $resdate = undef; |
131 |
my $expdate = undef; |
132 |
my $notes = ''; |
133 |
my $checkitem = undef; |
134 |
my $found = undef; |
135 |
|
136 |
my $branchcode = Koha::Libraries->search->next->branchcode; |
128 |
my $branchcode = Koha::Libraries->search->next->branchcode; |
137 |
|
129 |
|
138 |
AddReserve($branchcode, $borrowernumber, $biblionumber, |
130 |
AddReserve( |
139 |
$bibitems, $priority, $resdate, $expdate, $notes, |
131 |
{ |
140 |
$title, $checkitem, $found); |
132 |
branchcode => $branchcode, |
|
|
133 |
borrowernumber => $borrowernumber, |
134 |
biblionumber => $biblionumber, |
135 |
priority => 1, |
136 |
} |
137 |
); |
141 |
|
138 |
|
142 |
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); |
139 |
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); |
143 |
|
140 |
|
Lines 260-274
my ($itemnum_cpl, $itemnum_fpl);
Link Here
|
260 |
# Ensure that priorities are numbered correcly when a hold is moved to waiting |
257 |
# Ensure that priorities are numbered correcly when a hold is moved to waiting |
261 |
# (bug 11947) |
258 |
# (bug 11947) |
262 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
259 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
263 |
AddReserve($branch_3, $requesters{$branch_3}, $bibnum2, |
260 |
AddReserve( |
264 |
$bibitems, 1, $resdate, $expdate, $notes, |
261 |
{ |
265 |
$title, $checkitem, $found); |
262 |
branchcode => $branch_3, |
266 |
AddReserve($branch_2, $requesters{$branch_2}, $bibnum2, |
263 |
borrowernumber => $requesters{$branch_3}, |
267 |
$bibitems, 2, $resdate, $expdate, $notes, |
264 |
biblionumber => $bibnum2, |
268 |
$title, $checkitem, $found); |
265 |
priority => 1, |
269 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum2, |
266 |
} |
270 |
$bibitems, 3, $resdate, $expdate, $notes, |
267 |
); |
271 |
$title, $checkitem, $found); |
268 |
AddReserve( |
|
|
269 |
{ |
270 |
branchcode => $branch_2, |
271 |
borrowernumber => $requesters{$branch_2}, |
272 |
biblionumber => $bibnum2, |
273 |
priority => 2, |
274 |
} |
275 |
); |
276 |
AddReserve( |
277 |
{ |
278 |
branchcode => $branch_1, |
279 |
borrowernumber => $requesters{$branch_1}, |
280 |
biblionumber => $bibnum2, |
281 |
priority => 3, |
282 |
} |
283 |
); |
272 |
ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0); |
284 |
ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0); |
273 |
|
285 |
|
274 |
# Now it should have different priorities. |
286 |
# Now it should have different priorities. |
Lines 284-298
is( $reserves[0]->borrowernumber(), $requesters{$branch_3}, 'GetWaiting got the
Link Here
|
284 |
|
296 |
|
285 |
|
297 |
|
286 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
298 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
287 |
AddReserve($branch_3, $requesters{$branch_3}, $bibnum2, |
299 |
AddReserve( |
288 |
$bibitems, 1, $resdate, $expdate, $notes, |
300 |
{ |
289 |
$title, $checkitem, $found); |
301 |
branchcode => $branch_3, |
290 |
AddReserve($branch_2, $requesters{$branch_2}, $bibnum2, |
302 |
borrowernumber => $requesters{$branch_3}, |
291 |
$bibitems, 2, $resdate, $expdate, $notes, |
303 |
biblionumber => $bibnum2, |
292 |
$title, $checkitem, $found); |
304 |
priority => 1, |
293 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum2, |
305 |
} |
294 |
$bibitems, 3, $resdate, $expdate, $notes, |
306 |
); |
295 |
$title, $checkitem, $found); |
307 |
AddReserve( |
|
|
308 |
{ |
309 |
branchcode => $branch_2, |
310 |
borrowernumber => $requesters{$branch_2}, |
311 |
biblionumber => $bibnum2, |
312 |
priority => 2, |
313 |
} |
314 |
); |
315 |
|
316 |
AddReserve( |
317 |
{ |
318 |
branchcode => $branch_1, |
319 |
borrowernumber => $requesters{$branch_1}, |
320 |
biblionumber => $bibnum2, |
321 |
priority => 3, |
322 |
} |
323 |
); |
296 |
|
324 |
|
297 |
# Ensure that the item's home library controls hold policy lookup |
325 |
# Ensure that the item's home library controls hold policy lookup |
298 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); |
326 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); |
Lines 326-337
my $reserve_id = $holds->next->reserve_id;
Link Here
|
326 |
# Tests for bug 9761 (ConfirmFutureHolds): new CheckReserves lookahead parameter, and corresponding change in AddReturn |
354 |
# Tests for bug 9761 (ConfirmFutureHolds): new CheckReserves lookahead parameter, and corresponding change in AddReturn |
327 |
# Note that CheckReserve uses its lookahead parameter and does not check ConfirmFutureHolds pref (it should be passed if needed like AddReturn does) |
355 |
# Note that CheckReserve uses its lookahead parameter and does not check ConfirmFutureHolds pref (it should be passed if needed like AddReturn does) |
328 |
# Test 9761a: Add a reserve without date, CheckReserve should return it |
356 |
# Test 9761a: Add a reserve without date, CheckReserve should return it |
329 |
$resdate= undef; #defaults to today in AddReserve |
|
|
330 |
$expdate= undef; #no expdate |
331 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
357 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
332 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
358 |
AddReserve( |
333 |
$bibitems, 1, $resdate, $expdate, $notes, |
359 |
{ |
334 |
$title, $checkitem, $found); |
360 |
branchcode => $branch_1, |
|
|
361 |
borrowernumber => $requesters{$branch_1}, |
362 |
biblionumber => $bibnum, |
363 |
priority => 1, |
364 |
} |
365 |
); |
335 |
($status)=CheckReserves($itemnumber,undef,undef); |
366 |
($status)=CheckReserves($itemnumber,undef,undef); |
336 |
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead'); |
367 |
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead'); |
337 |
($status)=CheckReserves($itemnumber,undef,7); |
368 |
($status)=CheckReserves($itemnumber,undef,7); |
Lines 340-352
is( $status, 'Reserved', 'CheckReserves also returns reserve with lookahead');
Link Here
|
340 |
# Test 9761b: Add a reserve with future date, CheckReserve should not return it |
371 |
# Test 9761b: Add a reserve with future date, CheckReserve should not return it |
341 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
372 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
342 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
373 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
343 |
$resdate= dt_from_string(); |
374 |
my $resdate= dt_from_string(); |
344 |
$resdate->add_duration(DateTime::Duration->new(days => 4)); |
375 |
$resdate->add_duration(DateTime::Duration->new(days => 4)); |
345 |
$resdate=output_pref($resdate); |
376 |
$resdate=output_pref($resdate); |
346 |
$expdate= undef; #no expdate |
377 |
AddReserve( |
347 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
378 |
{ |
348 |
$bibitems, 1, $resdate, $expdate, $notes, |
379 |
branchcode => $branch_1, |
349 |
$title, $checkitem, $found); |
380 |
borrowernumber => $requesters{$branch_1}, |
|
|
381 |
biblionumber => $bibnum, |
382 |
priority => 1, |
383 |
reservation_date => $resdate, |
384 |
} |
385 |
); |
350 |
($status)=CheckReserves($itemnumber,undef,undef); |
386 |
($status)=CheckReserves($itemnumber,undef,undef); |
351 |
is( $status, '', 'CheckReserves returns no future reserve without lookahead'); |
387 |
is( $status, '', 'CheckReserves returns no future reserve without lookahead'); |
352 |
|
388 |
|
Lines 401-409
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
Link Here
|
401 |
$resdate= dt_from_string(); |
437 |
$resdate= dt_from_string(); |
402 |
$resdate->add_duration(DateTime::Duration->new(days => 2)); |
438 |
$resdate->add_duration(DateTime::Duration->new(days => 2)); |
403 |
$resdate=output_pref($resdate); |
439 |
$resdate=output_pref($resdate); |
404 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
440 |
AddReserve( |
405 |
$bibitems, 1, $resdate, $expdate, $notes, |
441 |
{ |
406 |
$title, $checkitem, $found); |
442 |
branchcode => $branch_1, |
|
|
443 |
borrowernumber => $requesters{$branch_1}, |
444 |
biblionumber => $bibnum, |
445 |
priority => 1, |
446 |
reservation_date => $resdate, |
447 |
} |
448 |
); |
449 |
|
407 |
my $item = Koha::Items->find( $itemnumber ); |
450 |
my $item = Koha::Items->find( $itemnumber ); |
408 |
$holds = $item->current_holds; |
451 |
$holds = $item->current_holds; |
409 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
452 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
Lines 411-419
my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( d
Link Here
|
411 |
is( $future_holds->count, 0, 'current_holds does not return a future next available hold'); |
454 |
is( $future_holds->count, 0, 'current_holds does not return a future next available hold'); |
412 |
# 9788b: current_holds does not return future item level hold |
455 |
# 9788b: current_holds does not return future item level hold |
413 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
456 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
414 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
457 |
AddReserve( |
415 |
$bibitems, 1, $resdate, $expdate, $notes, |
458 |
{ |
416 |
$title, $itemnumber, $found); #item level hold |
459 |
branchcode => $branch_1, |
|
|
460 |
borrowernumber => $requesters{$branch_1}, |
461 |
biblionumber => $bibnum, |
462 |
priority => 1, |
463 |
reservation_date => $resdate, |
464 |
itemnumber => $itemnumber, |
465 |
} |
466 |
); #item level hold |
417 |
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); |
467 |
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); |
418 |
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); |
468 |
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); |
419 |
# 9788c: current_holds returns future wait (confirmed future hold) |
469 |
# 9788c: current_holds returns future wait (confirmed future hold) |
Lines 426-435
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
Link Here
|
426 |
# Tests for CalculatePriority (bug 8918) |
476 |
# Tests for CalculatePriority (bug 8918) |
427 |
my $p = C4::Reserves::CalculatePriority($bibnum2); |
477 |
my $p = C4::Reserves::CalculatePriority($bibnum2); |
428 |
is($p, 4, 'CalculatePriority should now return priority 4'); |
478 |
is($p, 4, 'CalculatePriority should now return priority 4'); |
429 |
$resdate=undef; |
479 |
AddReserve( |
430 |
AddReserve($branch_1, $requesters{'CPL2'}, $bibnum2, |
480 |
{ |
431 |
$bibitems, $p, $resdate, $expdate, $notes, |
481 |
branchcode => $branch_1, |
432 |
$title, $checkitem, $found); |
482 |
borrowernumber => $requesters{'CPL2'}, |
|
|
483 |
biblionumber => $bibnum2, |
484 |
priority => $p, |
485 |
} |
486 |
); |
433 |
$p = C4::Reserves::CalculatePriority($bibnum2); |
487 |
$p = C4::Reserves::CalculatePriority($bibnum2); |
434 |
is($p, 5, 'CalculatePriority should now return priority 5'); |
488 |
is($p, 5, 'CalculatePriority should now return priority 5'); |
435 |
#some tests on bibnum |
489 |
#some tests on bibnum |
Lines 437-463
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
Link Here
|
437 |
$p = C4::Reserves::CalculatePriority($bibnum); |
491 |
$p = C4::Reserves::CalculatePriority($bibnum); |
438 |
is($p, 1, 'CalculatePriority should now return priority 1'); |
492 |
is($p, 1, 'CalculatePriority should now return priority 1'); |
439 |
#add a new reserve and confirm it to waiting |
493 |
#add a new reserve and confirm it to waiting |
440 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
494 |
AddReserve( |
441 |
$bibitems, $p, $resdate, $expdate, $notes, |
495 |
{ |
442 |
$title, $itemnumber, $found); |
496 |
branchcode => $branch_1, |
|
|
497 |
borrowernumber => $requesters{$branch_1}, |
498 |
biblionumber => $bibnum, |
499 |
priority => $p, |
500 |
itemnumber => $itemnumber, |
501 |
} |
502 |
); |
443 |
$p = C4::Reserves::CalculatePriority($bibnum); |
503 |
$p = C4::Reserves::CalculatePriority($bibnum); |
444 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
504 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
445 |
ModReserveAffect( $itemnumber, $requesters{$branch_1} , 0); |
505 |
ModReserveAffect( $itemnumber, $requesters{$branch_1} , 0); |
446 |
$p = C4::Reserves::CalculatePriority($bibnum); |
506 |
$p = C4::Reserves::CalculatePriority($bibnum); |
447 |
is($p, 1, 'CalculatePriority should now return priority 1'); |
507 |
is($p, 1, 'CalculatePriority should now return priority 1'); |
448 |
#add another biblio hold, no resdate |
508 |
#add another biblio hold, no resdate |
449 |
AddReserve($branch_1, $requesters{'CPL2'}, $bibnum, |
509 |
AddReserve( |
450 |
$bibitems, $p, $resdate, $expdate, $notes, |
510 |
{ |
451 |
$title, $checkitem, $found); |
511 |
branchcode => $branch_1, |
|
|
512 |
borrowernumber => $requesters{'CPL2'}, |
513 |
biblionumber => $bibnum, |
514 |
priority => $p, |
515 |
} |
516 |
); |
452 |
$p = C4::Reserves::CalculatePriority($bibnum); |
517 |
$p = C4::Reserves::CalculatePriority($bibnum); |
453 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
518 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
454 |
#add another future hold |
519 |
#add another future hold |
455 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
520 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
456 |
$resdate= dt_from_string(); |
521 |
$resdate= dt_from_string(); |
457 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
522 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
458 |
AddReserve($branch_1, $requesters{'CPL3'}, $bibnum, |
523 |
AddReserve( |
459 |
$bibitems, $p, output_pref($resdate), $expdate, $notes, |
524 |
{ |
460 |
$title, $checkitem, $found); |
525 |
branchcode => $branch_1, |
|
|
526 |
borrowernumber => $requesters{'CPL2'}, |
527 |
biblionumber => $bibnum, |
528 |
priority => $p, |
529 |
reservation_date => output_pref($resdate), |
530 |
} |
531 |
); |
461 |
$p = C4::Reserves::CalculatePriority($bibnum); |
532 |
$p = C4::Reserves::CalculatePriority($bibnum); |
462 |
is($p, 2, 'CalculatePriority should now still return priority 2'); |
533 |
is($p, 2, 'CalculatePriority should now still return priority 2'); |
463 |
#calc priority with future resdate |
534 |
#calc priority with future resdate |
Lines 467-475
is($p, 3, 'CalculatePriority should now return priority 3');
Link Here
|
467 |
|
538 |
|
468 |
# Tests for cancel reserves by users from OPAC. |
539 |
# Tests for cancel reserves by users from OPAC. |
469 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
540 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
470 |
AddReserve($branch_1, $requesters{$branch_1}, $item_bibnum, |
541 |
AddReserve( |
471 |
$bibitems, 1, undef, $expdate, $notes, |
542 |
{ |
472 |
$title, $checkitem, ''); |
543 |
branchcode => $branch_1, |
|
|
544 |
borrowernumber => $requesters{$branch_1}, |
545 |
biblionumber => $item_bibnum, |
546 |
priority => 1, |
547 |
} |
548 |
); |
473 |
my (undef, $canres, undef) = CheckReserves($itemnumber); |
549 |
my (undef, $canres, undef) = CheckReserves($itemnumber); |
474 |
|
550 |
|
475 |
is( CanReserveBeCanceledFromOpac(), undef, |
551 |
is( CanReserveBeCanceledFromOpac(), undef, |
Lines 497-505
$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$br
Link Here
|
497 |
is($cancancel, 0, 'Reserve in transfer status cant be canceled'); |
573 |
is($cancancel, 0, 'Reserve in transfer status cant be canceled'); |
498 |
|
574 |
|
499 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
575 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
500 |
AddReserve($branch_1, $requesters{$branch_1}, $item_bibnum, |
576 |
AddReserve( |
501 |
$bibitems, 1, undef, $expdate, $notes, |
577 |
{ |
502 |
$title, $checkitem, ''); |
578 |
branchcode => $branch_1, |
|
|
579 |
borrowernumber => $requesters{$branch_1}, |
580 |
biblionumber => $item_bibnum, |
581 |
priority => 1, |
582 |
} |
583 |
); |
503 |
(undef, $canres, undef) = CheckReserves($itemnumber); |
584 |
(undef, $canres, undef) = CheckReserves($itemnumber); |
504 |
|
585 |
|
505 |
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0); |
586 |
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0); |
Lines 548-561
ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $borrower), "Reserving a
Link Here
|
548 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
629 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
549 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0); |
630 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0); |
550 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
631 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
551 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
632 |
AddReserve( |
552 |
$bibitems, 1, undef, $expdate, $notes, $title, $checkitem, ''); |
633 |
{ |
|
|
634 |
branchcode => $branch_1, |
635 |
borrowernumber => $borrowernumber, |
636 |
biblionumber => $item_bibnum, |
637 |
priority => 1, |
638 |
} |
639 |
); |
553 |
MoveReserve( $itemnumber, $borrowernumber ); |
640 |
MoveReserve( $itemnumber, $borrowernumber ); |
554 |
($status)=CheckReserves( $itemnumber ); |
641 |
($status)=CheckReserves( $itemnumber ); |
555 |
is( $status, '', 'MoveReserve filled hold'); |
642 |
is( $status, '', 'MoveReserve filled hold'); |
556 |
# hold from A waiting, today, no fut holds: MoveReserve should fill it |
643 |
# hold from A waiting, today, no fut holds: MoveReserve should fill it |
557 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
644 |
AddReserve( |
558 |
$bibitems, 1, undef, $expdate, $notes, $title, $checkitem, 'W'); |
645 |
{ |
|
|
646 |
branchcode => $branch_1, |
647 |
borrowernumber => $borrowernumber, |
648 |
biblionumber => $item_bibnum, |
649 |
priority => 1, |
650 |
found => 'W', |
651 |
} |
652 |
); |
559 |
MoveReserve( $itemnumber, $borrowernumber ); |
653 |
MoveReserve( $itemnumber, $borrowernumber ); |
560 |
($status)=CheckReserves( $itemnumber ); |
654 |
($status)=CheckReserves( $itemnumber ); |
561 |
is( $status, '', 'MoveReserve filled waiting hold'); |
655 |
is( $status, '', 'MoveReserve filled waiting hold'); |
Lines 563-584
is( $status, '', 'MoveReserve filled waiting hold');
Link Here
|
563 |
$resdate= dt_from_string(); |
657 |
$resdate= dt_from_string(); |
564 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
658 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
565 |
$resdate=output_pref($resdate); |
659 |
$resdate=output_pref($resdate); |
566 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
660 |
AddReserve( |
567 |
$bibitems, 1, $resdate, $expdate, $notes, $title, $checkitem, ''); |
661 |
{ |
|
|
662 |
branchcode => $branch_1, |
663 |
borrowernumber => $borrowernumber, |
664 |
biblionumber => $item_bibnum, |
665 |
priority => 1, |
666 |
reservation_date => $resdate, |
667 |
} |
668 |
); |
568 |
MoveReserve( $itemnumber, $borrowernumber ); |
669 |
MoveReserve( $itemnumber, $borrowernumber ); |
569 |
($status)=CheckReserves( $itemnumber, undef, 1 ); |
670 |
($status)=CheckReserves( $itemnumber, undef, 1 ); |
570 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold'); |
671 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold'); |
571 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
672 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
572 |
# hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it |
673 |
# hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it |
573 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2); |
674 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2); |
574 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
675 |
AddReserve( |
575 |
$bibitems, 1, $resdate, $expdate, $notes, $title, $checkitem, ''); |
676 |
{ |
|
|
677 |
branchcode => $branch_1, |
678 |
borrowernumber => $borrowernumber, |
679 |
biblionumber => $item_bibnum, |
680 |
priority => 1, |
681 |
reservation_date => $resdate, |
682 |
} |
683 |
); |
576 |
MoveReserve( $itemnumber, $borrowernumber ); |
684 |
MoveReserve( $itemnumber, $borrowernumber ); |
577 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
685 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
578 |
is( $status, '', 'MoveReserve filled future hold now'); |
686 |
is( $status, '', 'MoveReserve filled future hold now'); |
579 |
# hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it |
687 |
# hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it |
580 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
688 |
AddReserve( |
581 |
$bibitems, 1, $resdate, $expdate, $notes, $title, $checkitem, 'W'); |
689 |
{ |
|
|
690 |
branchcode => $branch_1, |
691 |
borrowernumber => $borrowernumber, |
692 |
biblionumber => $item_bibnum, |
693 |
priority => 1, |
694 |
reservation_date => $resdate, |
695 |
} |
696 |
); |
582 |
MoveReserve( $itemnumber, $borrowernumber ); |
697 |
MoveReserve( $itemnumber, $borrowernumber ); |
583 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
698 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
584 |
is( $status, '', 'MoveReserve filled future waiting hold now'); |
699 |
is( $status, '', 'MoveReserve filled future waiting hold now'); |
Lines 586-593
is( $status, '', 'MoveReserve filled future waiting hold now');
Link Here
|
586 |
$resdate= dt_from_string(); |
701 |
$resdate= dt_from_string(); |
587 |
$resdate->add_duration(DateTime::Duration->new(days => 3)); |
702 |
$resdate->add_duration(DateTime::Duration->new(days => 3)); |
588 |
$resdate=output_pref($resdate); |
703 |
$resdate=output_pref($resdate); |
589 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
704 |
AddReserve( |
590 |
$bibitems, 1, $resdate, $expdate, $notes, $title, $checkitem, ''); |
705 |
{ |
|
|
706 |
branchcode => $branch_1, |
707 |
borrowernumber => $borrowernumber, |
708 |
biblionumber => $item_bibnum, |
709 |
priority => 1, |
710 |
reservation_date => $resdate, |
711 |
} |
712 |
); |
591 |
MoveReserve( $itemnumber, $borrowernumber ); |
713 |
MoveReserve( $itemnumber, $borrowernumber ); |
592 |
($status)=CheckReserves( $itemnumber, undef, 3 ); |
714 |
($status)=CheckReserves( $itemnumber, undef, 3 ); |
593 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
715 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
Lines 648-655
subtest '_koha_notify_reserve() tests' => sub {
Link Here
|
648 |
})->{borrowernumber}; |
770 |
})->{borrowernumber}; |
649 |
|
771 |
|
650 |
C4::Reserves::AddReserve( |
772 |
C4::Reserves::AddReserve( |
651 |
$item->{homebranch}, $hold_borrower, |
773 |
{ |
652 |
$item->{biblionumber} ); |
774 |
branchcode => $item->{homebranch}, |
|
|
775 |
borrowernumber => $hold_borrower, |
776 |
biblionumber => $item->{biblionumber}, |
777 |
} |
778 |
); |
653 |
|
779 |
|
654 |
ModReserveAffect($item->{itemnumber}, $hold_borrower, 0); |
780 |
ModReserveAffect($item->{itemnumber}, $hold_borrower, 0); |
655 |
my $sms_message_address = $schema->resultset('MessageQueue')->search({ |
781 |
my $sms_message_address = $schema->resultset('MessageQueue')->search({ |
Lines 694-704
subtest 'ReservesNeedReturns' => sub {
Link Here
|
694 |
|
820 |
|
695 |
t::lib::Mocks::mock_preference('ReservesNeedReturns', 0); # '0' means 'Automatically mark a hold as found and waiting' |
821 |
t::lib::Mocks::mock_preference('ReservesNeedReturns', 0); # '0' means 'Automatically mark a hold as found and waiting' |
696 |
$hold_id = C4::Reserves::AddReserve( |
822 |
$hold_id = C4::Reserves::AddReserve( |
697 |
$library->branchcode, $patron->borrowernumber, |
823 |
{ |
698 |
$item->biblionumber, '', |
824 |
branchcode => $library->branchcode, |
699 |
$priority, undef, |
825 |
borrowernumber => $patron->borrowernumber, |
700 |
undef, '', |
826 |
biblionumber => $item->biblionumber, |
701 |
"title for fee", $item->itemnumber, |
827 |
priority => $priority, |
|
|
828 |
title => "title for fee", |
829 |
itemnumber => $item->itemnumber, |
830 |
} |
702 |
); |
831 |
); |
703 |
$hold = Koha::Holds->find($hold_id); |
832 |
$hold = Koha::Holds->find($hold_id); |
704 |
is( $hold->priority, 0, 'If ReservesNeedReturns is 0, priority must have been set to 0' ); |
833 |
is( $hold->priority, 0, 'If ReservesNeedReturns is 0, priority must have been set to 0' ); |
Lines 708-718
subtest 'ReservesNeedReturns' => sub {
Link Here
|
708 |
|
837 |
|
709 |
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # '0' means "Don't automatically mark a hold as found and waiting" |
838 |
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # '0' means "Don't automatically mark a hold as found and waiting" |
710 |
$hold_id = C4::Reserves::AddReserve( |
839 |
$hold_id = C4::Reserves::AddReserve( |
711 |
$library->branchcode, $patron->borrowernumber, |
840 |
{ |
712 |
$item->biblionumber, '', |
841 |
branchcode => $library->branchcode, |
713 |
$priority, undef, |
842 |
borrowernumber => $patron->borrowernumber, |
714 |
undef, '', |
843 |
biblionumber => $item->biblionumber, |
715 |
"title for fee", $item->itemnumber, |
844 |
priority => $priority, |
|
|
845 |
title => "title for fee", |
846 |
itemnumber => $item->itemnumber, |
847 |
} |
716 |
); |
848 |
); |
717 |
$hold = Koha::Holds->find($hold_id); |
849 |
$hold = Koha::Holds->find($hold_id); |
718 |
is( $hold->priority, $priority, 'If ReservesNeedReturns is 1, priority must not have been set to changed' ); |
850 |
is( $hold->priority, $priority, 'If ReservesNeedReturns is 1, priority must not have been set to changed' ); |