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

(-)a/t/db_dependent/Reserves.t (-2 / +52 lines)
Lines 2-9 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 8;
5
use Test::More tests => 16;
6
use MARC::Record;
6
use MARC::Record;
7
use DateTime::Duration;
7
8
8
use C4::Branch;
9
use C4::Branch;
9
use C4::Biblio;
10
use C4::Biblio;
Lines 11-16 use C4::Items; Link Here
11
use C4::Members;
12
use C4::Members;
12
use C4::Circulation;
13
use C4::Circulation;
13
14
15
use Koha::DateUtils;
16
14
BEGIN {
17
BEGIN {
15
    use_ok('C4::Reserves');
18
    use_ok('C4::Reserves');
16
}
19
}
Lines 212-215 is( $messages->{ResFound}->{borrowernumber}, Link Here
212
    $requesters{'RPL'},
215
    $requesters{'RPL'},
213
    'for generous library, its items fill first hold request in line (bug 10272)');
216
    'for generous library, its items fill first hold request in line (bug 10272)');
214
217
218
# Tests for bug 9761 (ConfirmFutureHolds): new CheckReserves lookahead parameter, and corresponding change in AddReturn
219
# Note that CheckReserve uses its lookahead parameter and does not check ConfirmFutureHolds pref (it should be passed if needed like AddReturn does)
220
# Test 9761a: Add a reserve without date, CheckReserve should return it
221
$resdate= undef; #defaults to today in AddReserve
222
$expdate= undef; #no expdate
223
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
224
AddReserve('CPL',  $requesters{'CPL'}, $bibnum,
225
           $constraint, $bibitems,  1, $resdate, $expdate, $notes,
226
           $title,      $checkitem, $found);
227
($status)=CheckReserves($itemnumber,undef,undef);
228
is( $status, 'Reserved', 'CheckReserves returns reserve without lookahead');
229
($status)=CheckReserves($itemnumber,undef,7);
230
is( $status, 'Reserved', 'CheckReserves also returns reserve with lookahead');
231
232
# Test 9761b: Add a reserve with future date, CheckReserve should not return it
233
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
234
C4::Context->set_preference('AllowHoldDateInFuture', 1);
235
$resdate= dt_from_string();
236
$resdate->add_duration(DateTime::Duration->new(days => 4));
237
$resdate=output_pref($resdate);
238
$expdate= undef; #no expdate
239
AddReserve('CPL',  $requesters{'CPL'}, $bibnum,
240
           $constraint, $bibitems,  1, $resdate, $expdate, $notes,
241
           $title,      $checkitem, $found);
242
($status)=CheckReserves($itemnumber,undef,undef);
243
is( $status, '', 'CheckReserves returns no future reserve without lookahead');
244
245
# Test 9761c: Add a reserve with future date, CheckReserve should return it if lookahead is high enough
246
($status)=CheckReserves($itemnumber,undef,3);
247
is( $status, '', 'CheckReserves returns no future reserve with insufficient lookahead');
248
($status)=CheckReserves($itemnumber,undef,4);
249
is( $status, 'Reserved', 'CheckReserves returns future reserve with sufficient lookahead');
250
251
# Test 9761d: Check ResFound message of AddReturn for future hold
252
# Note that AddReturn is in Circulation.pm, but this test really pertains to reserves; AddReturn uses the ConfirmFutureHolds pref when calling CheckReserves
253
# In this test we do not need an issued item; it is just a 'checkin'
254
C4::Context->set_preference('ConfirmFutureHolds', 0);
255
(my $doreturn, $messages)= AddReturn('97531','CPL');
256
is($messages->{ResFound}//'', '', 'AddReturn does not care about future reserve when ConfirmFutureHolds is off');
257
C4::Context->set_preference('ConfirmFutureHolds', 3);
258
($doreturn, $messages)= AddReturn('97531','CPL');
259
is(exists $messages->{ResFound}?1:0, 0, 'AddReturn ignores future reserve beyond ConfirmFutureHolds days');
260
C4::Context->set_preference('ConfirmFutureHolds', 7);
261
($doreturn, $messages)= AddReturn('97531','CPL');
262
is(exists $messages->{ResFound}?1:0, 1, 'AddReturn considers future reserve within ConfirmFutureHolds days');
263
264
# End of tests for bug 9761 (ConfirmFutureHolds)
265
215
$dbh->rollback;
266
$dbh->rollback;
216
- 

Return to bug 9761