Lines 79-100
my $itemtype = $builder->build(
Link Here
|
79 |
|
79 |
|
80 |
t::lib::Mocks::mock_userenv({ branchcode => $branch_1 }); |
80 |
t::lib::Mocks::mock_userenv({ branchcode => $branch_1 }); |
81 |
|
81 |
|
82 |
# Create a helper biblio |
82 |
my $bibnum = $builder->gimme_a_biblio({frameworkcode => $frameworkcode})->biblionumber; |
83 |
my $bib = MARC::Record->new(); |
|
|
84 |
my $title = 'Silence in the library'; |
85 |
if( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { |
86 |
$bib->append_fields( |
87 |
MARC::Field->new('600', '', '1', a => 'Moffat, Steven'), |
88 |
MARC::Field->new('200', '', '', a => $title), |
89 |
); |
90 |
} |
91 |
else { |
92 |
$bib->append_fields( |
93 |
MARC::Field->new('100', '', '', a => 'Moffat, Steven'), |
94 |
MARC::Field->new('245', '', '', a => $title), |
95 |
); |
96 |
} |
97 |
my ( $bibnum ) = AddBiblio($bib, $frameworkcode); |
98 |
|
83 |
|
99 |
# Create a helper item instance for testing |
84 |
# Create a helper item instance for testing |
100 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
85 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
Lines 135-141
my $branchcode = Koha::Libraries->search->next->branchcode;
Link Here
|
135 |
|
120 |
|
136 |
AddReserve($branchcode, $borrowernumber, $biblionumber, |
121 |
AddReserve($branchcode, $borrowernumber, $biblionumber, |
137 |
$bibitems, $priority, $resdate, $expdate, $notes, |
122 |
$bibitems, $priority, $resdate, $expdate, $notes, |
138 |
$title, $checkitem, $found); |
123 |
'a title', $checkitem, $found); |
139 |
|
124 |
|
140 |
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); |
125 |
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); |
141 |
|
126 |
|
Lines 227-241
$dbh->do(
Link Here
|
227 |
$branch_2, 10, 2, 'homebranch', |
212 |
$branch_2, 10, 2, 'homebranch', |
228 |
); |
213 |
); |
229 |
|
214 |
|
230 |
# helper biblio for the bug 10272 regression test |
215 |
my $bibnum2 = $builder->gimme_a_biblio({frameworkcode => $frameworkcode})->biblionumber; |
231 |
my $bib2 = MARC::Record->new(); |
|
|
232 |
$bib2->append_fields( |
233 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
234 |
MARC::Field->new('245', ' ', ' ', a => $title), |
235 |
); |
236 |
|
216 |
|
237 |
# create one item belonging to FPL and one belonging to CPL |
|
|
238 |
my ( $bibnum2 ) = AddBiblio($bib, $frameworkcode); |
239 |
my ($itemnum_cpl, $itemnum_fpl); |
217 |
my ($itemnum_cpl, $itemnum_fpl); |
240 |
( undef, undef, $itemnum_cpl ) = AddItem( |
218 |
( undef, undef, $itemnum_cpl ) = AddItem( |
241 |
{ homebranch => $branch_1, |
219 |
{ homebranch => $branch_1, |
Lines 260-272
my ($itemnum_cpl, $itemnum_fpl);
Link Here
|
260 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
238 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
261 |
AddReserve($branch_3, $requesters{$branch_3}, $bibnum2, |
239 |
AddReserve($branch_3, $requesters{$branch_3}, $bibnum2, |
262 |
$bibitems, 1, $resdate, $expdate, $notes, |
240 |
$bibitems, 1, $resdate, $expdate, $notes, |
263 |
$title, $checkitem, $found); |
241 |
'a title', $checkitem, $found); |
264 |
AddReserve($branch_2, $requesters{$branch_2}, $bibnum2, |
242 |
AddReserve($branch_2, $requesters{$branch_2}, $bibnum2, |
265 |
$bibitems, 2, $resdate, $expdate, $notes, |
243 |
$bibitems, 2, $resdate, $expdate, $notes, |
266 |
$title, $checkitem, $found); |
244 |
'a title', $checkitem, $found); |
267 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum2, |
245 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum2, |
268 |
$bibitems, 3, $resdate, $expdate, $notes, |
246 |
$bibitems, 3, $resdate, $expdate, $notes, |
269 |
$title, $checkitem, $found); |
247 |
'a title', $checkitem, $found); |
270 |
ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0); |
248 |
ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0); |
271 |
|
249 |
|
272 |
# Now it should have different priorities. |
250 |
# Now it should have different priorities. |
Lines 284-296
is( $reserves[0]->borrowernumber(), $requesters{$branch_3}, 'GetWaiting got the
Link Here
|
284 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
262 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); |
285 |
AddReserve($branch_3, $requesters{$branch_3}, $bibnum2, |
263 |
AddReserve($branch_3, $requesters{$branch_3}, $bibnum2, |
286 |
$bibitems, 1, $resdate, $expdate, $notes, |
264 |
$bibitems, 1, $resdate, $expdate, $notes, |
287 |
$title, $checkitem, $found); |
265 |
'a title', $checkitem, $found); |
288 |
AddReserve($branch_2, $requesters{$branch_2}, $bibnum2, |
266 |
AddReserve($branch_2, $requesters{$branch_2}, $bibnum2, |
289 |
$bibitems, 2, $resdate, $expdate, $notes, |
267 |
$bibitems, 2, $resdate, $expdate, $notes, |
290 |
$title, $checkitem, $found); |
268 |
'a title', $checkitem, $found); |
291 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum2, |
269 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum2, |
292 |
$bibitems, 3, $resdate, $expdate, $notes, |
270 |
$bibitems, 3, $resdate, $expdate, $notes, |
293 |
$title, $checkitem, $found); |
271 |
'a title', $checkitem, $found); |
294 |
|
272 |
|
295 |
# Ensure that the item's home library controls hold policy lookup |
273 |
# Ensure that the item's home library controls hold policy lookup |
296 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); |
274 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); |
Lines 329-335
$expdate= undef; #no expdate
Link Here
|
329 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
307 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
330 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
308 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
331 |
$bibitems, 1, $resdate, $expdate, $notes, |
309 |
$bibitems, 1, $resdate, $expdate, $notes, |
332 |
$title, $checkitem, $found); |
310 |
'a title', $checkitem, $found); |
333 |
($status)=CheckReserves($itemnumber,undef,undef); |
311 |
($status)=CheckReserves($itemnumber,undef,undef); |
334 |
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead'); |
312 |
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead'); |
335 |
($status)=CheckReserves($itemnumber,undef,7); |
313 |
($status)=CheckReserves($itemnumber,undef,7); |
Lines 344-350
$resdate=output_pref($resdate);
Link Here
|
344 |
$expdate= undef; #no expdate |
322 |
$expdate= undef; #no expdate |
345 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
323 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
346 |
$bibitems, 1, $resdate, $expdate, $notes, |
324 |
$bibitems, 1, $resdate, $expdate, $notes, |
347 |
$title, $checkitem, $found); |
325 |
'a title', $checkitem, $found); |
348 |
($status)=CheckReserves($itemnumber,undef,undef); |
326 |
($status)=CheckReserves($itemnumber,undef,undef); |
349 |
is( $status, '', 'CheckReserves returns no future reserve without lookahead'); |
327 |
is( $status, '', 'CheckReserves returns no future reserve without lookahead'); |
350 |
|
328 |
|
Lines 401-407
$resdate->add_duration(DateTime::Duration->new(days => 2));
Link Here
|
401 |
$resdate=output_pref($resdate); |
379 |
$resdate=output_pref($resdate); |
402 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
380 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
403 |
$bibitems, 1, $resdate, $expdate, $notes, |
381 |
$bibitems, 1, $resdate, $expdate, $notes, |
404 |
$title, $checkitem, $found); |
382 |
'a title', $checkitem, $found); |
405 |
my $item = Koha::Items->find( $itemnumber ); |
383 |
my $item = Koha::Items->find( $itemnumber ); |
406 |
$holds = $item->current_holds; |
384 |
$holds = $item->current_holds; |
407 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
385 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
Lines 411-417
is( $future_holds->count, 0, 'current_holds does not return a future next availa
Link Here
|
411 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
389 |
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); |
412 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
390 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
413 |
$bibitems, 1, $resdate, $expdate, $notes, |
391 |
$bibitems, 1, $resdate, $expdate, $notes, |
414 |
$title, $itemnumber, $found); #item level hold |
392 |
'a title', $itemnumber, $found); #item level hold |
415 |
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); |
393 |
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); |
416 |
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); |
394 |
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); |
417 |
# 9788c: current_holds returns future wait (confirmed future hold) |
395 |
# 9788c: current_holds returns future wait (confirmed future hold) |
Lines 427-433
is($p, 4, 'CalculatePriority should now return priority 4');
Link Here
|
427 |
$resdate=undef; |
405 |
$resdate=undef; |
428 |
AddReserve($branch_1, $requesters{'CPL2'}, $bibnum2, |
406 |
AddReserve($branch_1, $requesters{'CPL2'}, $bibnum2, |
429 |
$bibitems, $p, $resdate, $expdate, $notes, |
407 |
$bibitems, $p, $resdate, $expdate, $notes, |
430 |
$title, $checkitem, $found); |
408 |
'a title', $checkitem, $found); |
431 |
$p = C4::Reserves::CalculatePriority($bibnum2); |
409 |
$p = C4::Reserves::CalculatePriority($bibnum2); |
432 |
is($p, 5, 'CalculatePriority should now return priority 5'); |
410 |
is($p, 5, 'CalculatePriority should now return priority 5'); |
433 |
#some tests on bibnum |
411 |
#some tests on bibnum |
Lines 437-443
is($p, 1, 'CalculatePriority should now return priority 1');
Link Here
|
437 |
#add a new reserve and confirm it to waiting |
415 |
#add a new reserve and confirm it to waiting |
438 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
416 |
AddReserve($branch_1, $requesters{$branch_1}, $bibnum, |
439 |
$bibitems, $p, $resdate, $expdate, $notes, |
417 |
$bibitems, $p, $resdate, $expdate, $notes, |
440 |
$title, $itemnumber, $found); |
418 |
'a title', $itemnumber, $found); |
441 |
$p = C4::Reserves::CalculatePriority($bibnum); |
419 |
$p = C4::Reserves::CalculatePriority($bibnum); |
442 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
420 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
443 |
ModReserveAffect( $itemnumber, $requesters{$branch_1} , 0); |
421 |
ModReserveAffect( $itemnumber, $requesters{$branch_1} , 0); |
Lines 446-452
is($p, 1, 'CalculatePriority should now return priority 1');
Link Here
|
446 |
#add another biblio hold, no resdate |
424 |
#add another biblio hold, no resdate |
447 |
AddReserve($branch_1, $requesters{'CPL2'}, $bibnum, |
425 |
AddReserve($branch_1, $requesters{'CPL2'}, $bibnum, |
448 |
$bibitems, $p, $resdate, $expdate, $notes, |
426 |
$bibitems, $p, $resdate, $expdate, $notes, |
449 |
$title, $checkitem, $found); |
427 |
'a title', $checkitem, $found); |
450 |
$p = C4::Reserves::CalculatePriority($bibnum); |
428 |
$p = C4::Reserves::CalculatePriority($bibnum); |
451 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
429 |
is($p, 2, 'CalculatePriority should now return priority 2'); |
452 |
#add another future hold |
430 |
#add another future hold |
Lines 455-461
$resdate= dt_from_string();
Link Here
|
455 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
433 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
456 |
AddReserve($branch_1, $requesters{'CPL3'}, $bibnum, |
434 |
AddReserve($branch_1, $requesters{'CPL3'}, $bibnum, |
457 |
$bibitems, $p, output_pref($resdate), $expdate, $notes, |
435 |
$bibitems, $p, output_pref($resdate), $expdate, $notes, |
458 |
$title, $checkitem, $found); |
436 |
'a title', $checkitem, $found); |
459 |
$p = C4::Reserves::CalculatePriority($bibnum); |
437 |
$p = C4::Reserves::CalculatePriority($bibnum); |
460 |
is($p, 2, 'CalculatePriority should now still return priority 2'); |
438 |
is($p, 2, 'CalculatePriority should now still return priority 2'); |
461 |
#calc priority with future resdate |
439 |
#calc priority with future resdate |
Lines 467-473
is($p, 3, 'CalculatePriority should now return priority 3');
Link Here
|
467 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
445 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
468 |
AddReserve($branch_1, $requesters{$branch_1}, $item_bibnum, |
446 |
AddReserve($branch_1, $requesters{$branch_1}, $item_bibnum, |
469 |
$bibitems, 1, undef, $expdate, $notes, |
447 |
$bibitems, 1, undef, $expdate, $notes, |
470 |
$title, $checkitem, ''); |
448 |
'a title', $checkitem, ''); |
471 |
my (undef, $canres, undef) = CheckReserves($itemnumber); |
449 |
my (undef, $canres, undef) = CheckReserves($itemnumber); |
472 |
|
450 |
|
473 |
is( CanReserveBeCanceledFromOpac(), undef, |
451 |
is( CanReserveBeCanceledFromOpac(), undef, |
Lines 497-503
is($cancancel, 0, 'Reserve in transfer status cant be canceled');
Link Here
|
497 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
475 |
$dbh->do('DELETE FROM reserves', undef, ($bibnum)); |
498 |
AddReserve($branch_1, $requesters{$branch_1}, $item_bibnum, |
476 |
AddReserve($branch_1, $requesters{$branch_1}, $item_bibnum, |
499 |
$bibitems, 1, undef, $expdate, $notes, |
477 |
$bibitems, 1, undef, $expdate, $notes, |
500 |
$title, $checkitem, ''); |
478 |
'a title', $checkitem, ''); |
501 |
(undef, $canres, undef) = CheckReserves($itemnumber); |
479 |
(undef, $canres, undef) = CheckReserves($itemnumber); |
502 |
|
480 |
|
503 |
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0); |
481 |
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0); |
Lines 547-559
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
Link Here
|
547 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0); |
525 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0); |
548 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
526 |
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); |
549 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
527 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
550 |
$bibitems, 1, undef, $expdate, $notes, $title, $checkitem, ''); |
528 |
$bibitems, 1, undef, $expdate, $notes, 'a title', $checkitem, ''); |
551 |
MoveReserve( $itemnumber, $borrowernumber ); |
529 |
MoveReserve( $itemnumber, $borrowernumber ); |
552 |
($status)=CheckReserves( $itemnumber ); |
530 |
($status)=CheckReserves( $itemnumber ); |
553 |
is( $status, '', 'MoveReserve filled hold'); |
531 |
is( $status, '', 'MoveReserve filled hold'); |
554 |
# hold from A waiting, today, no fut holds: MoveReserve should fill it |
532 |
# hold from A waiting, today, no fut holds: MoveReserve should fill it |
555 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
533 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
556 |
$bibitems, 1, undef, $expdate, $notes, $title, $checkitem, 'W'); |
534 |
$bibitems, 1, undef, $expdate, $notes, 'a title', $checkitem, 'W'); |
557 |
MoveReserve( $itemnumber, $borrowernumber ); |
535 |
MoveReserve( $itemnumber, $borrowernumber ); |
558 |
($status)=CheckReserves( $itemnumber ); |
536 |
($status)=CheckReserves( $itemnumber ); |
559 |
is( $status, '', 'MoveReserve filled waiting hold'); |
537 |
is( $status, '', 'MoveReserve filled waiting hold'); |
Lines 562-568
$resdate= dt_from_string();
Link Here
|
562 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
540 |
$resdate->add_duration(DateTime::Duration->new(days => 1)); |
563 |
$resdate=output_pref($resdate); |
541 |
$resdate=output_pref($resdate); |
564 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
542 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
565 |
$bibitems, 1, $resdate, $expdate, $notes, $title, $checkitem, ''); |
543 |
$bibitems, 1, $resdate, $expdate, $notes, 'a title', $checkitem, ''); |
566 |
MoveReserve( $itemnumber, $borrowernumber ); |
544 |
MoveReserve( $itemnumber, $borrowernumber ); |
567 |
($status)=CheckReserves( $itemnumber, undef, 1 ); |
545 |
($status)=CheckReserves( $itemnumber, undef, 1 ); |
568 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold'); |
546 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold'); |
Lines 570-582
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
Link Here
|
570 |
# hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it |
548 |
# hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it |
571 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2); |
549 |
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2); |
572 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
550 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
573 |
$bibitems, 1, $resdate, $expdate, $notes, $title, $checkitem, ''); |
551 |
$bibitems, 1, $resdate, $expdate, $notes, 'a title', $checkitem, ''); |
574 |
MoveReserve( $itemnumber, $borrowernumber ); |
552 |
MoveReserve( $itemnumber, $borrowernumber ); |
575 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
553 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
576 |
is( $status, '', 'MoveReserve filled future hold now'); |
554 |
is( $status, '', 'MoveReserve filled future hold now'); |
577 |
# hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it |
555 |
# hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it |
578 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
556 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
579 |
$bibitems, 1, $resdate, $expdate, $notes, $title, $checkitem, 'W'); |
557 |
$bibitems, 1, $resdate, $expdate, $notes, 'a title', $checkitem, 'W'); |
580 |
MoveReserve( $itemnumber, $borrowernumber ); |
558 |
MoveReserve( $itemnumber, $borrowernumber ); |
581 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
559 |
($status)=CheckReserves( $itemnumber, undef, 2 ); |
582 |
is( $status, '', 'MoveReserve filled future waiting hold now'); |
560 |
is( $status, '', 'MoveReserve filled future waiting hold now'); |
Lines 585-591
$resdate= dt_from_string();
Link Here
|
585 |
$resdate->add_duration(DateTime::Duration->new(days => 3)); |
563 |
$resdate->add_duration(DateTime::Duration->new(days => 3)); |
586 |
$resdate=output_pref($resdate); |
564 |
$resdate=output_pref($resdate); |
587 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
565 |
AddReserve($branch_1, $borrowernumber, $item_bibnum, |
588 |
$bibitems, 1, $resdate, $expdate, $notes, $title, $checkitem, ''); |
566 |
$bibitems, 1, $resdate, $expdate, $notes, 'a title', $checkitem, ''); |
589 |
MoveReserve( $itemnumber, $borrowernumber ); |
567 |
MoveReserve( $itemnumber, $borrowernumber ); |
590 |
($status)=CheckReserves( $itemnumber, undef, 3 ); |
568 |
($status)=CheckReserves( $itemnumber, undef, 3 ); |
591 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
569 |
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); |
592 |
- |
|
|