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

(-)a/t/db_dependent/Holds.t (-5 / +31 lines)
Lines 7-13 use t::lib::TestBuilder; Link Here
7
7
8
use C4::Context;
8
use C4::Context;
9
9
10
use Test::More tests => 53;
10
use Test::More tests => 56;
11
use MARC::Record;
11
use MARC::Record;
12
use C4::Biblio;
12
use C4::Biblio;
13
use C4::Items;
13
use C4::Items;
Lines 388-397 $dbh->do('DELETE FROM biblio'); Link Here
388
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum );
388
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum );
389
389
390
$dbh->do(
390
$dbh->do(
391
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
391
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record, holds_per_day)
392
      VALUES (?, ?, ?, ?, ?)},
392
      VALUES (?, ?, ?, ?, ?, ?)},
393
    {},
393
    {},
394
    '*', '*', 'ONLY1', 1, 99
394
    '*', '*', 'ONLY1', 1, 99, 2
395
);
395
);
396
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
396
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
397
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
397
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
Lines 401-406 my $res_id = AddReserve( $branch_1, $borrowernumbers[0], $bibnum, '', 1, ); Link Here
401
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
401
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
402
    'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' );
402
    'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' );
403
403
404
# Add two more items
405
my ( $bibnum_2, undef, $bibitemnum_2 ) = create_helper_biblio('ONLY1');
406
my ( undef, undef, $itemnumber_2 )
407
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum_2 );
408
my ( $bibnum_3, undef, $bibitemnum_3 ) = create_helper_biblio('ONLY1');
409
my ( undef, undef, $itemnumber_3 )
410
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum_3 );
411
# Raise reservesallowed to avoid tooManyReserves
412
$dbh->do(q{
413
    UPDATE issuingrules SET reservesallowed=3 WHERE itemtype='ONLY1'
414
});
415
416
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber_2 ),
417
    'OK', 'Patron can reserve item with hold limit of 1, 1 bib level hold placed, 2 reserves daily cap' );
418
419
# Add a second reserve
420
$res_id = AddReserve( $branch_1, $borrowernumbers[0], $bibnum_2, '', 1, );
421
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber_2 ),
422
    'tooManyReservesToday', 'Patron cannot reserve item with hold limit of 3, 2 bib level hold placed on the same day, 2 reserves daily cap' );
423
424
# Update last hold so reservedate is in the past, so 2 holds, but different day
425
$hold = Koha::Holds->find( $res_id );
426
my $yesterday = dt_from_string() - DateTime::Duration->new( days => 1 ) ;
427
$hold->reservedate( $yesterday )->store;
428
429
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber_2 ),
430
    'OK', 'Patron can reserve item with hold limit of 3, 2 bib level hold placed on different days, 2 reserves daily cap' );
404
431
405
# Helper method to set up a Biblio.
432
# Helper method to set up a Biblio.
406
sub create_helper_biblio {
433
sub create_helper_biblio {
407
- 

Return to bug 15486