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 => 38;
9
use Test::More tests => 40;
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 34-39 my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)'); Link Here
34
$insert_sth->execute('CAN');
34
$insert_sth->execute('CAN');
35
$insert_sth->execute('CANNOT');
35
$insert_sth->execute('CANNOT');
36
$insert_sth->execute('DUMMY');
36
$insert_sth->execute('DUMMY');
37
$insert_sth->execute('ONLY1');
37
38
38
# Setup Test------------------------
39
# Setup Test------------------------
39
# Create a biblio instance for testing
40
# Create a biblio instance for testing
Lines 193-211 my ($foreign_item_bibnum, $foreign_item_bibitemnum, $foreign_itemnumber) Link Here
193
$dbh->do('DELETE FROM issuingrules');
194
$dbh->do('DELETE FROM issuingrules');
194
$dbh->do(
195
$dbh->do(
195
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
196
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
196
      VALUES (?, ?, ?, ?)}, 
197
      VALUES (?, ?, ?, ?)},
197
    {},
198
    {},
198
    '*', '*', '*', 25
199
    '*', '*', '*', 25
199
);
200
);
200
$dbh->do(
201
$dbh->do(
201
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
202
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
202
      VALUES (?, ?, ?, ?)}, 
203
      VALUES (?, ?, ?, ?)},
203
    {},
204
    {},
204
    '*', '*', 'CANNOT', 0 
205
    '*', '*', 'CANNOT', 0
206
);
207
$dbh->do(
208
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
209
      VALUES (?, ?, ?, ?)},
210
    {},
211
    '*', '*', 'ONLY1', 1
205
);
212
);
206
213
207
# make sure some basic sysprefs are set
214
# make sure some basic sysprefs are set
208
t::lib::Mocks::mock_preference('ReservesControlBranch', 'homebranch');
215
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
209
t::lib::Mocks::mock_preference('item-level_itypes', 1);
216
t::lib::Mocks::mock_preference('item-level_itypes', 1);
210
217
211
# if IndependentBranches is OFF, a CPL patron can reserve an MPL item
218
# if IndependentBranches is OFF, a CPL patron can reserve an MPL item
Lines 365-370 CancelExpiredReserves(); Link Here
365
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
372
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
366
is( $count, 0, "Reserve with manual expiration date canceled correctly" );
373
is( $count, 0, "Reserve with manual expiration date canceled correctly" );
367
374
375
# Bug 12632
376
t::lib::Mocks::mock_preference( 'item-level_itypes',     1 );
377
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' );
378
379
$dbh->do('DELETE FROM reserves');
380
$dbh->do('DELETE FROM issues');
381
$dbh->do('DELETE FROM items');
382
$dbh->do('DELETE FROM biblio');
383
384
( $bibnum, $title, $bibitemnum ) = create_helper_biblio('ONLY1');
385
( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( { homebranch => 'CPL', holdingbranch => 'CPL' }, $bibnum );
386
387
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
388
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
389
390
my $res_id = AddReserve( $branch, $borrowernumbers[0], $bibnum, 'a', '', 1, );
391
392
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
393
    'tooManyReserves', 'Patron can reserve item with hold limit of 1, no holds placed' );
394
395
368
# Helper method to set up a Biblio.
396
# Helper method to set up a Biblio.
369
sub create_helper_biblio {
397
sub create_helper_biblio {
370
    my $itemtype = shift;
398
    my $itemtype = shift;
371
- 

Return to bug 12632