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

(-)a/t/db_dependent/Reserves.t (-5 / +18 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 71;
20
use Test::More tests => 72;
21
21
22
use MARC::Record;
22
use MARC::Record;
23
use DateTime::Duration;
23
use DateTime::Duration;
Lines 153-158 $requesters{'CPL'} = AddMember( Link Here
153
    categorycode => 'PT',
153
    categorycode => 'PT',
154
    surname      => 'borrower from CPL',
154
    surname      => 'borrower from CPL',
155
);
155
);
156
for my $i ( 2 .. 5 ) {
157
    $requesters{"CPL$i"} = AddMember(
158
        branchcode   => 'CPL',
159
        categorycode => 'PT',
160
        surname      => 'borrower $i from CPL',
161
    );
162
}
156
$requesters{'FPL'} = AddMember(
163
$requesters{'FPL'} = AddMember(
157
    branchcode   => 'FPL',
164
    branchcode   => 'FPL',
158
    categorycode => 'PT',
165
    categorycode => 'PT',
Lines 393-403 ModReserveAffect( $itemnumber, $requesters{'CPL'} , 0); #confirm hold Link Here
393
is(defined $results[3]?1:0, 1, 'GetReservesFromItemnumber returns a future wait (confirmed future hold)');
400
is(defined $results[3]?1:0, 1, 'GetReservesFromItemnumber returns a future wait (confirmed future hold)');
394
# End of tests for bug 9788
401
# End of tests for bug 9788
395
402
403
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
396
# Tests for CalculatePriority (bug 8918)
404
# Tests for CalculatePriority (bug 8918)
397
my $p = C4::Reserves::CalculatePriority($bibnum2);
405
my $p = C4::Reserves::CalculatePriority($bibnum2);
398
is($p, 4, 'CalculatePriority should now return priority 4');
406
is($p, 4, 'CalculatePriority should now return priority 4');
399
$resdate=undef;
407
$resdate=undef;
400
AddReserve('CPL',  $requesters{'CPL'}, $bibnum2,
408
AddReserve('CPL',  $requesters{'CPL2'}, $bibnum2,
401
           $bibitems,  $p, $resdate, $expdate, $notes,
409
           $bibitems,  $p, $resdate, $expdate, $notes,
402
           $title,      $checkitem, $found);
410
           $title,      $checkitem, $found);
403
$p = C4::Reserves::CalculatePriority($bibnum2);
411
$p = C4::Reserves::CalculatePriority($bibnum2);
Lines 416-422 ModReserveAffect( $itemnumber, $requesters{'CPL'} , 0); Link Here
416
$p = C4::Reserves::CalculatePriority($bibnum);
424
$p = C4::Reserves::CalculatePriority($bibnum);
417
is($p, 1, 'CalculatePriority should now return priority 1');
425
is($p, 1, 'CalculatePriority should now return priority 1');
418
#add another biblio hold, no resdate
426
#add another biblio hold, no resdate
419
AddReserve('CPL',  $requesters{'CPL'}, $bibnum,
427
AddReserve('CPL',  $requesters{'CPL2'}, $bibnum,
420
           $bibitems,  $p, $resdate, $expdate, $notes,
428
           $bibitems,  $p, $resdate, $expdate, $notes,
421
           $title,      $checkitem, $found);
429
           $title,      $checkitem, $found);
422
$p = C4::Reserves::CalculatePriority($bibnum);
430
$p = C4::Reserves::CalculatePriority($bibnum);
Lines 425-431 is($p, 2, 'CalculatePriority should now return priority 2'); Link Here
425
C4::Context->set_preference('AllowHoldDateInFuture', 1);
433
C4::Context->set_preference('AllowHoldDateInFuture', 1);
426
$resdate= dt_from_string();
434
$resdate= dt_from_string();
427
$resdate->add_duration(DateTime::Duration->new(days => 1));
435
$resdate->add_duration(DateTime::Duration->new(days => 1));
428
AddReserve('CPL',  $requesters{'CPL'}, $bibnum,
436
AddReserve('CPL',  $requesters{'CPL3'}, $bibnum,
429
           $bibitems,  $p, output_pref($resdate), $expdate, $notes,
437
           $bibitems,  $p, output_pref($resdate), $expdate, $notes,
430
           $title,      $checkitem, $found);
438
           $title,      $checkitem, $found);
431
$p = C4::Reserves::CalculatePriority($bibnum);
439
$p = C4::Reserves::CalculatePriority($bibnum);
Lines 435-440 $p = C4::Reserves::CalculatePriority($bibnum, $resdate); Link Here
435
is($p, 3, 'CalculatePriority should now return priority 3');
443
is($p, 3, 'CalculatePriority should now return priority 3');
436
# End of tests for bug 8918
444
# End of tests for bug 8918
437
445
446
# Test for bug 5144
447
$reserve_id = AddReserve('CPL',  $requesters{'CPL3'}, $bibnum,
448
           $bibitems,  $p, output_pref($resdate), $expdate, $notes,
449
           $title,      $checkitem, $found);
450
is( $reserve_id, undef, 'Attempt to add a second reserve on a given record for the same patron fails.' );
451
438
# Tests for cancel reserves by users from OPAC.
452
# Tests for cancel reserves by users from OPAC.
439
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
453
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
440
AddReserve('CPL',  $requesters{'CPL'}, $item_bibnum,
454
AddReserve('CPL',  $requesters{'CPL'}, $item_bibnum,
441
- 

Return to bug 5144