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 => 58;
10
use Test::More tests => 61;
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 449-458 $dbh->do('DELETE FROM biblio'); Link Here
449
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum );
449
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum );
450
450
451
$dbh->do(
451
$dbh->do(
452
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
452
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record, holds_per_day)
453
      VALUES (?, ?, ?, ?, ?)},
453
      VALUES (?, ?, ?, ?, ?, ?)},
454
    {},
454
    {},
455
    '*', '*', 'ONLY1', 1, 99
455
    '*', '*', 'ONLY1', 1, 99, 2
456
);
456
);
457
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
457
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
458
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
458
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
Lines 462-467 my $res_id = AddReserve( $branch_1, $borrowernumbers[0], $bibnum, '', 1, ); Link Here
462
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
462
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
463
    'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' );
463
    'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' );
464
464
465
# Add two more items
466
my ( $bibnum_2, undef, $bibitemnum_2 ) = create_helper_biblio('ONLY1');
467
my ( undef, undef, $itemnumber_2 )
468
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum_2 );
469
my ( $bibnum_3, undef, $bibitemnum_3 ) = create_helper_biblio('ONLY1');
470
my ( undef, undef, $itemnumber_3 )
471
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum_3 );
472
# Raise reservesallowed to avoid tooManyReserves
473
$dbh->do(q{
474
    UPDATE issuingrules SET reservesallowed=3 WHERE itemtype='ONLY1'
475
});
476
477
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber_2 ),
478
    'OK', 'Patron can reserve item with hold limit of 1, 1 bib level hold placed, 2 reserves daily cap' );
479
480
# Add a second reserve
481
$res_id = AddReserve( $branch_1, $borrowernumbers[0], $bibnum_2, '', 1, );
482
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber_2 ),
483
    'tooManyReservesToday', 'Patron cannot reserve item with hold limit of 3, 2 bib level hold placed on the same day, 2 reserves daily cap' );
484
485
# Update last hold so reservedate is in the past, so 2 holds, but different day
486
$hold = Koha::Holds->find( $res_id );
487
my $yesterday = dt_from_string() - DateTime::Duration->new( days => 1 ) ;
488
$hold->reservedate( $yesterday )->store;
489
490
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber_2 ),
491
    'OK', 'Patron can reserve item with hold limit of 3, 2 bib level hold placed on different days, 2 reserves daily cap' );
465
492
466
# Helper method to set up a Biblio.
493
# Helper method to set up a Biblio.
467
sub create_helper_biblio {
494
sub create_helper_biblio {
468
- 

Return to bug 15486