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

(-)a/t/db_dependent/Reserves.t (-3 / +35 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 25;
5
use Test::More tests => 31;
6
use MARC::Record;
6
use MARC::Record;
7
use DateTime::Duration;
7
use DateTime::Duration;
8
8
Lines 320-330 is(defined $results[3]?1:0, 1, 'GetReservesFromItemnumber returns a future wait Link Here
320
# Tests for CalculatePriority (bug 8918)
320
# Tests for CalculatePriority (bug 8918)
321
my $p = C4::Reserves::CalculatePriority($bibnum2);
321
my $p = C4::Reserves::CalculatePriority($bibnum2);
322
is($p, 4, 'CalculatePriority  should now return priority 4');
322
is($p, 4, 'CalculatePriority  should now return priority 4');
323
$resdate=undef;
323
AddReserve('CPL',  $requesters{'CPL'}, $bibnum2,
324
AddReserve('CPL',  $requesters{'CPL'}, $bibnum2,
324
           $constraint, $bibitems,  $p, undef, $expdate, $notes,
325
           $constraint, $bibitems,  $p, $resdate, $expdate, $notes,
325
           $title,      $checkitem, $found);
326
           $title,      $checkitem, $found);
326
$p = C4::Reserves::CalculatePriority($bibnum2);
327
$p = C4::Reserves::CalculatePriority($bibnum2);
327
is($p, 5, 'CalculatePriority should now return priority 5');
328
is($p, 5, 'CalculatePriority should now return priority 5');
329
#some tests on bibnum
330
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
331
$p = C4::Reserves::CalculatePriority($bibnum);
332
is($p, 1, 'CalculatePriority  should now return priority 1');
333
#add a new reserve and confirm it to waiting
334
AddReserve('CPL',  $requesters{'CPL'}, $bibnum,
335
           $constraint, $bibitems,  $p, $resdate, $expdate, $notes,
336
           $title,      $itemnumber, $found);
337
$p = C4::Reserves::CalculatePriority($bibnum);
338
is($p, 2, 'CalculatePriority  should now return priority 2');
339
ModReserveAffect( $itemnumber,  $requesters{'CPL'} , 0);
340
$p = C4::Reserves::CalculatePriority($bibnum);
341
is($p, 1, 'CalculatePriority  should now return priority 1');
342
#add another biblio hold, no resdate
343
AddReserve('CPL',  $requesters{'CPL'}, $bibnum,
344
           $constraint, $bibitems,  $p, $resdate, $expdate, $notes,
345
           $title,      $checkitem, $found);
346
$p = C4::Reserves::CalculatePriority($bibnum);
347
is($p, 2, 'CalculatePriority  should now return priority 2');
348
#add another future hold
349
C4::Context->set_preference('AllowHoldDateInFuture', 1);
350
$resdate= dt_from_string();
351
$resdate->add_duration(DateTime::Duration->new(days => 1));
352
$resdate=output_pref($resdate);
353
AddReserve('CPL',  $requesters{'CPL'}, $bibnum,
354
           $constraint, $bibitems,  $p, $resdate, $expdate, $notes,
355
           $title,      $checkitem, $found);
356
$p = C4::Reserves::CalculatePriority($bibnum);
357
is($p, 2, 'CalculatePriority  should now still return priority 2');
358
#calc priority with future resdate
359
$p = C4::Reserves::CalculatePriority($bibnum, $resdate);
360
is($p, 3, 'CalculatePriority  should now return priority 3');
328
# End of tests for bug 8918
361
# End of tests for bug 8918
329
362
330
$dbh->rollback;
363
$dbh->rollback;
331
- 

Return to bug 8918