View | Details | Raw Unified | Return to bug 21798
Collapse All | Expand All

(-)a/t/db_dependent/Labels/t_Label.t (-16 / +1 lines)
Lines 58-79 my $itemtype = Link Here
58
58
59
C4::Context->set_userenv( undef, undef, undef, undef, undef, undef, $branch_1 );
59
C4::Context->set_userenv( undef, undef, undef, undef, undef, undef, $branch_1 );
60
60
61
# Create a helper biblio
61
my $bibnum = $builder->gimme_a_biblio({ frameworkcode => $frameworkcode })->biblionumber;
62
my $bib   = MARC::Record->new();
63
my $title = 'Silence in the library';
64
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
65
    $bib->append_fields(
66
        MARC::Field->new( '600', q{}, '1', a => 'Moffat, Steven' ),
67
        MARC::Field->new( '200', q{}, q{}, a => $title ),
68
    );
69
}
70
else {
71
    $bib->append_fields(
72
        MARC::Field->new( '100', q{}, q{}, a => 'Moffat, Steven' ),
73
        MARC::Field->new( '245', q{}, q{}, a => $title ),
74
    );
75
}
76
my ($bibnum) = AddBiblio( $bib, $frameworkcode );
77
62
78
# Create a helper item instance for testing
63
# Create a helper item instance for testing
79
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem(
64
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem(
(-)a/t/db_dependent/Reserves.t (-48 / +25 lines)
Lines 81-102 C4::Context->set_userenv( Link Here
81
    undef, undef, undef, undef, undef, undef, $branch_1
81
    undef, undef, undef, undef, undef, undef, $branch_1
82
);
82
);
83
83
84
# Create a helper biblio
84
my $bibnum = $builder->gimme_a_biblio({frameworkcode => $frameworkcode})->biblionumber;
85
my $bib = MARC::Record->new();
86
my $title = 'Silence in the library';
87
if( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
88
    $bib->append_fields(
89
        MARC::Field->new('600', '', '1', a => 'Moffat, Steven'),
90
        MARC::Field->new('200', '', '', a => $title),
91
    );
92
}
93
else {
94
    $bib->append_fields(
95
        MARC::Field->new('100', '', '', a => 'Moffat, Steven'),
96
        MARC::Field->new('245', '', '', a => $title),
97
    );
98
}
99
my ( $bibnum ) = AddBiblio($bib, $frameworkcode);
100
85
101
# Create a helper item instance for testing
86
# Create a helper item instance for testing
102
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem(
87
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem(
Lines 137-143 my $branchcode = Koha::Libraries->search->next->branchcode; Link Here
137
122
138
AddReserve($branchcode,    $borrowernumber, $biblionumber,
123
AddReserve($branchcode,    $borrowernumber, $biblionumber,
139
        $bibitems,  $priority, $resdate, $expdate, $notes,
124
        $bibitems,  $priority, $resdate, $expdate, $notes,
140
        $title,      $checkitem, $found);
125
        'a title',      $checkitem, $found);
141
126
142
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode);
127
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode);
143
128
Lines 229-243 $dbh->do( Link Here
229
    $branch_2, 10, 2, 'homebranch',
214
    $branch_2, 10, 2, 'homebranch',
230
);
215
);
231
216
232
# helper biblio for the bug 10272 regression test
217
my $bibnum2 = $builder->gimme_a_biblio({frameworkcode => $frameworkcode})->biblionumber;
233
my $bib2 = MARC::Record->new();
234
$bib2->append_fields(
235
    MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
236
    MARC::Field->new('245', ' ', ' ', a => $title),
237
);
238
218
239
# create one item belonging to FPL and one belonging to CPL
240
my ( $bibnum2 ) = AddBiblio($bib, $frameworkcode);
241
my ($itemnum_cpl, $itemnum_fpl);
219
my ($itemnum_cpl, $itemnum_fpl);
242
( undef, undef, $itemnum_cpl ) = AddItem(
220
( undef, undef, $itemnum_cpl ) = AddItem(
243
    {   homebranch    => $branch_1,
221
    {   homebranch    => $branch_1,
Lines 262-274 my ($itemnum_cpl, $itemnum_fpl); Link Here
262
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2));
240
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2));
263
AddReserve($branch_3,  $requesters{$branch_3}, $bibnum2,
241
AddReserve($branch_3,  $requesters{$branch_3}, $bibnum2,
264
           $bibitems,  1, $resdate, $expdate, $notes,
242
           $bibitems,  1, $resdate, $expdate, $notes,
265
           $title,      $checkitem, $found);
243
           'a title',      $checkitem, $found);
266
AddReserve($branch_2,  $requesters{$branch_2}, $bibnum2,
244
AddReserve($branch_2,  $requesters{$branch_2}, $bibnum2,
267
           $bibitems,  2, $resdate, $expdate, $notes,
245
           $bibitems,  2, $resdate, $expdate, $notes,
268
           $title,      $checkitem, $found);
246
           'a title',      $checkitem, $found);
269
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum2,
247
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum2,
270
           $bibitems,  3, $resdate, $expdate, $notes,
248
           $bibitems,  3, $resdate, $expdate, $notes,
271
           $title,      $checkitem, $found);
249
           'a title',      $checkitem, $found);
272
ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0);
250
ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0);
273
251
274
# Now it should have different priorities.
252
# Now it should have different priorities.
Lines 286-298 is( $reserves[0]->borrowernumber(), $requesters{$branch_3}, 'GetWaiting got the Link Here
286
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2));
264
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2));
287
AddReserve($branch_3,  $requesters{$branch_3}, $bibnum2,
265
AddReserve($branch_3,  $requesters{$branch_3}, $bibnum2,
288
           $bibitems,  1, $resdate, $expdate, $notes,
266
           $bibitems,  1, $resdate, $expdate, $notes,
289
           $title,      $checkitem, $found);
267
           'a title',      $checkitem, $found);
290
AddReserve($branch_2,  $requesters{$branch_2}, $bibnum2,
268
AddReserve($branch_2,  $requesters{$branch_2}, $bibnum2,
291
           $bibitems,  2, $resdate, $expdate, $notes,
269
           $bibitems,  2, $resdate, $expdate, $notes,
292
           $title,      $checkitem, $found);
270
           'a title',      $checkitem, $found);
293
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum2,
271
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum2,
294
           $bibitems,  3, $resdate, $expdate, $notes,
272
           $bibitems,  3, $resdate, $expdate, $notes,
295
           $title,      $checkitem, $found);
273
           'a title',      $checkitem, $found);
296
274
297
# Ensure that the item's home library controls hold policy lookup
275
# Ensure that the item's home library controls hold policy lookup
298
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
276
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
Lines 331-337 $expdate= undef; #no expdate Link Here
331
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
309
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
332
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
310
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
333
           $bibitems,  1, $resdate, $expdate, $notes,
311
           $bibitems,  1, $resdate, $expdate, $notes,
334
           $title,      $checkitem, $found);
312
           'a title',      $checkitem, $found);
335
($status)=CheckReserves($itemnumber,undef,undef);
313
($status)=CheckReserves($itemnumber,undef,undef);
336
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead');
314
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead');
337
($status)=CheckReserves($itemnumber,undef,7);
315
($status)=CheckReserves($itemnumber,undef,7);
Lines 346-352 $resdate=output_pref($resdate); Link Here
346
$expdate= undef; #no expdate
324
$expdate= undef; #no expdate
347
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
325
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
348
           $bibitems,  1, $resdate, $expdate, $notes,
326
           $bibitems,  1, $resdate, $expdate, $notes,
349
           $title,      $checkitem, $found);
327
           'a title',      $checkitem, $found);
350
($status)=CheckReserves($itemnumber,undef,undef);
328
($status)=CheckReserves($itemnumber,undef,undef);
351
is( $status, '', 'CheckReserves returns no future reserve without lookahead');
329
is( $status, '', 'CheckReserves returns no future reserve without lookahead');
352
330
Lines 403-409 $resdate->add_duration(DateTime::Duration->new(days => 2)); Link Here
403
$resdate=output_pref($resdate);
381
$resdate=output_pref($resdate);
404
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
382
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
405
           $bibitems,  1, $resdate, $expdate, $notes,
383
           $bibitems,  1, $resdate, $expdate, $notes,
406
           $title,      $checkitem, $found);
384
           'a title',      $checkitem, $found);
407
my $item = Koha::Items->find( $itemnumber );
385
my $item = Koha::Items->find( $itemnumber );
408
$holds = $item->current_holds;
386
$holds = $item->current_holds;
409
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
387
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
Lines 413-419 is( $future_holds->count, 0, 'current_holds does not return a future next availa Link Here
413
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
391
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
414
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
392
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
415
           $bibitems,  1, $resdate, $expdate, $notes,
393
           $bibitems,  1, $resdate, $expdate, $notes,
416
           $title,      $itemnumber, $found); #item level hold
394
           'a title',      $itemnumber, $found); #item level hold
417
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
395
$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' );
396
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)
397
# 9788c: current_holds returns future wait (confirmed future hold)
Lines 429-435 is($p, 4, 'CalculatePriority should now return priority 4'); Link Here
429
$resdate=undef;
407
$resdate=undef;
430
AddReserve($branch_1,  $requesters{'CPL2'}, $bibnum2,
408
AddReserve($branch_1,  $requesters{'CPL2'}, $bibnum2,
431
           $bibitems,  $p, $resdate, $expdate, $notes,
409
           $bibitems,  $p, $resdate, $expdate, $notes,
432
           $title,      $checkitem, $found);
410
           'a title',      $checkitem, $found);
433
$p = C4::Reserves::CalculatePriority($bibnum2);
411
$p = C4::Reserves::CalculatePriority($bibnum2);
434
is($p, 5, 'CalculatePriority should now return priority 5');
412
is($p, 5, 'CalculatePriority should now return priority 5');
435
#some tests on bibnum
413
#some tests on bibnum
Lines 439-445 is($p, 1, 'CalculatePriority should now return priority 1'); Link Here
439
#add a new reserve and confirm it to waiting
417
#add a new reserve and confirm it to waiting
440
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
418
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
441
           $bibitems,  $p, $resdate, $expdate, $notes,
419
           $bibitems,  $p, $resdate, $expdate, $notes,
442
           $title,      $itemnumber, $found);
420
           'a title',      $itemnumber, $found);
443
$p = C4::Reserves::CalculatePriority($bibnum);
421
$p = C4::Reserves::CalculatePriority($bibnum);
444
is($p, 2, 'CalculatePriority should now return priority 2');
422
is($p, 2, 'CalculatePriority should now return priority 2');
445
ModReserveAffect( $itemnumber,  $requesters{$branch_1} , 0);
423
ModReserveAffect( $itemnumber,  $requesters{$branch_1} , 0);
Lines 448-454 is($p, 1, 'CalculatePriority should now return priority 1'); Link Here
448
#add another biblio hold, no resdate
426
#add another biblio hold, no resdate
449
AddReserve($branch_1,  $requesters{'CPL2'}, $bibnum,
427
AddReserve($branch_1,  $requesters{'CPL2'}, $bibnum,
450
           $bibitems,  $p, $resdate, $expdate, $notes,
428
           $bibitems,  $p, $resdate, $expdate, $notes,
451
           $title,      $checkitem, $found);
429
           'a title',      $checkitem, $found);
452
$p = C4::Reserves::CalculatePriority($bibnum);
430
$p = C4::Reserves::CalculatePriority($bibnum);
453
is($p, 2, 'CalculatePriority should now return priority 2');
431
is($p, 2, 'CalculatePriority should now return priority 2');
454
#add another future hold
432
#add another future hold
Lines 457-463 $resdate= dt_from_string(); Link Here
457
$resdate->add_duration(DateTime::Duration->new(days => 1));
435
$resdate->add_duration(DateTime::Duration->new(days => 1));
458
AddReserve($branch_1,  $requesters{'CPL3'}, $bibnum,
436
AddReserve($branch_1,  $requesters{'CPL3'}, $bibnum,
459
           $bibitems,  $p, output_pref($resdate), $expdate, $notes,
437
           $bibitems,  $p, output_pref($resdate), $expdate, $notes,
460
           $title,      $checkitem, $found);
438
           'a title',      $checkitem, $found);
461
$p = C4::Reserves::CalculatePriority($bibnum);
439
$p = C4::Reserves::CalculatePriority($bibnum);
462
is($p, 2, 'CalculatePriority should now still return priority 2');
440
is($p, 2, 'CalculatePriority should now still return priority 2');
463
#calc priority with future resdate
441
#calc priority with future resdate
Lines 469-475 is($p, 3, 'CalculatePriority should now return priority 3'); Link Here
469
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
447
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
470
AddReserve($branch_1,  $requesters{$branch_1}, $item_bibnum,
448
AddReserve($branch_1,  $requesters{$branch_1}, $item_bibnum,
471
           $bibitems,  1, undef, $expdate, $notes,
449
           $bibitems,  1, undef, $expdate, $notes,
472
           $title,      $checkitem, '');
450
           'a title',      $checkitem, '');
473
my (undef, $canres, undef) = CheckReserves($itemnumber);
451
my (undef, $canres, undef) = CheckReserves($itemnumber);
474
452
475
is( CanReserveBeCanceledFromOpac(), undef,
453
is( CanReserveBeCanceledFromOpac(), undef,
Lines 499-505 is($cancancel, 0, 'Reserve in transfer status cant be canceled'); Link Here
499
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
477
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
500
AddReserve($branch_1,  $requesters{$branch_1}, $item_bibnum,
478
AddReserve($branch_1,  $requesters{$branch_1}, $item_bibnum,
501
           $bibitems,  1, undef, $expdate, $notes,
479
           $bibitems,  1, undef, $expdate, $notes,
502
           $title,      $checkitem, '');
480
           'a title',      $checkitem, '');
503
(undef, $canres, undef) = CheckReserves($itemnumber);
481
(undef, $canres, undef) = CheckReserves($itemnumber);
504
482
505
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0);
483
ModReserveAffect($itemnumber, $requesters{$branch_1}, 0);
Lines 549-561 $dbh->do('DELETE FROM reserves', undef, ($bibnum)); Link Here
549
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0);
527
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0);
550
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
528
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
551
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
529
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
552
    $bibitems,  1, undef, $expdate, $notes, $title, $checkitem, '');
530
    $bibitems,  1, undef, $expdate, $notes, 'a title', $checkitem, '');
553
MoveReserve( $itemnumber, $borrowernumber );
531
MoveReserve( $itemnumber, $borrowernumber );
554
($status)=CheckReserves( $itemnumber );
532
($status)=CheckReserves( $itemnumber );
555
is( $status, '', 'MoveReserve filled hold');
533
is( $status, '', 'MoveReserve filled hold');
556
#   hold from A waiting, today, no fut holds: MoveReserve should fill it
534
#   hold from A waiting, today, no fut holds: MoveReserve should fill it
557
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
535
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
558
   $bibitems,  1, undef, $expdate, $notes, $title, $checkitem, 'W');
536
   $bibitems,  1, undef, $expdate, $notes, 'a title', $checkitem, 'W');
559
MoveReserve( $itemnumber, $borrowernumber );
537
MoveReserve( $itemnumber, $borrowernumber );
560
($status)=CheckReserves( $itemnumber );
538
($status)=CheckReserves( $itemnumber );
561
is( $status, '', 'MoveReserve filled waiting hold');
539
is( $status, '', 'MoveReserve filled waiting hold');
Lines 564-570 $resdate= dt_from_string(); Link Here
564
$resdate->add_duration(DateTime::Duration->new(days => 1));
542
$resdate->add_duration(DateTime::Duration->new(days => 1));
565
$resdate=output_pref($resdate);
543
$resdate=output_pref($resdate);
566
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
544
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
567
    $bibitems,  1, $resdate, $expdate, $notes, $title, $checkitem, '');
545
    $bibitems,  1, $resdate, $expdate, $notes, 'a title', $checkitem, '');
568
MoveReserve( $itemnumber, $borrowernumber );
546
MoveReserve( $itemnumber, $borrowernumber );
569
($status)=CheckReserves( $itemnumber, undef, 1 );
547
($status)=CheckReserves( $itemnumber, undef, 1 );
570
is( $status, 'Reserved', 'MoveReserve did not fill future hold');
548
is( $status, 'Reserved', 'MoveReserve did not fill future hold');
Lines 572-584 $dbh->do('DELETE FROM reserves', undef, ($bibnum)); Link Here
572
#   hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it
550
#   hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it
573
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2);
551
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2);
574
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
552
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
575
    $bibitems,  1, $resdate, $expdate, $notes, $title, $checkitem, '');
553
    $bibitems,  1, $resdate, $expdate, $notes, 'a title', $checkitem, '');
576
MoveReserve( $itemnumber, $borrowernumber );
554
MoveReserve( $itemnumber, $borrowernumber );
577
($status)=CheckReserves( $itemnumber, undef, 2 );
555
($status)=CheckReserves( $itemnumber, undef, 2 );
578
is( $status, '', 'MoveReserve filled future hold now');
556
is( $status, '', 'MoveReserve filled future hold now');
579
#   hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it
557
#   hold from A waiting, tomorrow, fut holds=2: MoveReserve should fill it
580
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
558
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
581
    $bibitems,  1, $resdate, $expdate, $notes, $title, $checkitem, 'W');
559
    $bibitems,  1, $resdate, $expdate, $notes, 'a title', $checkitem, 'W');
582
MoveReserve( $itemnumber, $borrowernumber );
560
MoveReserve( $itemnumber, $borrowernumber );
583
($status)=CheckReserves( $itemnumber, undef, 2 );
561
($status)=CheckReserves( $itemnumber, undef, 2 );
584
is( $status, '', 'MoveReserve filled future waiting hold now');
562
is( $status, '', 'MoveReserve filled future waiting hold now');
Lines 587-593 $resdate= dt_from_string(); Link Here
587
$resdate->add_duration(DateTime::Duration->new(days => 3));
565
$resdate->add_duration(DateTime::Duration->new(days => 3));
588
$resdate=output_pref($resdate);
566
$resdate=output_pref($resdate);
589
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
567
AddReserve($branch_1,  $borrowernumber, $item_bibnum,
590
    $bibitems,  1, $resdate, $expdate, $notes, $title, $checkitem, '');
568
    $bibitems,  1, $resdate, $expdate, $notes, 'a title', $checkitem, '');
591
MoveReserve( $itemnumber, $borrowernumber );
569
MoveReserve( $itemnumber, $borrowernumber );
592
($status)=CheckReserves( $itemnumber, undef, 3 );
570
($status)=CheckReserves( $itemnumber, undef, 3 );
593
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days');
571
is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days');
594
- 

Return to bug 21798