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

(-)a/t/db_dependent/Holds.t (-6 / +33 lines)
Lines 6-12 use t::lib::Mocks; Link Here
6
use C4::Context;
6
use C4::Context;
7
use C4::Branch;
7
use C4::Branch;
8
8
9
use Test::More tests => 49;
9
use Test::More tests => 51;
10
use MARC::Record;
10
use MARC::Record;
11
use C4::Biblio;
11
use C4::Biblio;
12
use C4::Items;
12
use C4::Items;
Lines 37-42 my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)'); Link Here
37
$insert_sth->execute('CAN');
37
$insert_sth->execute('CAN');
38
$insert_sth->execute('CANNOT');
38
$insert_sth->execute('CANNOT');
39
$insert_sth->execute('DUMMY');
39
$insert_sth->execute('DUMMY');
40
$insert_sth->execute('ONLY1');
40
41
41
# Setup Test------------------------
42
# Setup Test------------------------
42
# Create a biblio instance for testing
43
# Create a biblio instance for testing
Lines 208-226 my ($foreign_item_bibnum, $foreign_item_bibitemnum, $foreign_itemnumber) Link Here
208
$dbh->do('DELETE FROM issuingrules');
209
$dbh->do('DELETE FROM issuingrules');
209
$dbh->do(
210
$dbh->do(
210
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
211
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
211
      VALUES (?, ?, ?, ?)}, 
212
      VALUES (?, ?, ?, ?)},
212
    {},
213
    {},
213
    '*', '*', '*', 25
214
    '*', '*', '*', 25
214
);
215
);
215
$dbh->do(
216
$dbh->do(
216
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
217
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
217
      VALUES (?, ?, ?, ?)}, 
218
      VALUES (?, ?, ?, ?)},
218
    {},
219
    {},
219
    '*', '*', 'CANNOT', 0 
220
    '*', '*', 'CANNOT', 0
220
);
221
);
221
222
222
# make sure some basic sysprefs are set
223
# make sure some basic sysprefs are set
223
t::lib::Mocks::mock_preference('ReservesControlBranch', 'homebranch');
224
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
224
t::lib::Mocks::mock_preference('item-level_itypes', 1);
225
t::lib::Mocks::mock_preference('item-level_itypes', 1);
225
226
226
# if IndependentBranches is OFF, a CPL patron can reserve an MPL item
227
# if IndependentBranches is OFF, a CPL patron can reserve an MPL item
Lines 416-421 CancelExpiredReserves(); Link Here
416
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
417
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
417
is( $count, 0, "Reserve with manual expiration date canceled correctly" );
418
is( $count, 0, "Reserve with manual expiration date canceled correctly" );
418
419
420
# Bug 12632
421
t::lib::Mocks::mock_preference( 'item-level_itypes',     1 );
422
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' );
423
424
$dbh->do('DELETE FROM reserves');
425
$dbh->do('DELETE FROM issues');
426
$dbh->do('DELETE FROM items');
427
$dbh->do('DELETE FROM biblio');
428
429
( $bibnum, $title, $bibitemnum ) = create_helper_biblio('ONLY1');
430
( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( { homebranch => 'CPL', holdingbranch => 'CPL' }, $bibnum );
431
432
$dbh->do(
433
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
434
      VALUES (?, ?, ?, ?)},
435
    {},
436
    '*', '*', 'ONLY1', 1
437
);
438
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
439
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
440
441
my $res_id = AddReserve( $branch, $borrowernumbers[0], $bibnum, '', 1, );
442
443
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
444
    'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' );
445
446
419
# Helper method to set up a Biblio.
447
# Helper method to set up a Biblio.
420
sub create_helper_biblio {
448
sub create_helper_biblio {
421
    my $itemtype = shift;
449
    my $itemtype = shift;
422
- 

Return to bug 12632