|
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 210-228
my ($foreign_item_bibnum, $foreign_item_bibitemnum, $foreign_itemnumber)
Link Here
|
| 210 |
$dbh->do('DELETE FROM issuingrules'); |
211 |
$dbh->do('DELETE FROM issuingrules'); |
| 211 |
$dbh->do( |
212 |
$dbh->do( |
| 212 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) |
213 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) |
| 213 |
VALUES (?, ?, ?, ?)}, |
214 |
VALUES (?, ?, ?, ?)}, |
| 214 |
{}, |
215 |
{}, |
| 215 |
'*', '*', '*', 25 |
216 |
'*', '*', '*', 25 |
| 216 |
); |
217 |
); |
| 217 |
$dbh->do( |
218 |
$dbh->do( |
| 218 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) |
219 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) |
| 219 |
VALUES (?, ?, ?, ?)}, |
220 |
VALUES (?, ?, ?, ?)}, |
| 220 |
{}, |
221 |
{}, |
| 221 |
'*', '*', 'CANNOT', 0 |
222 |
'*', '*', 'CANNOT', 0 |
| 222 |
); |
223 |
); |
| 223 |
|
224 |
|
| 224 |
# make sure some basic sysprefs are set |
225 |
# make sure some basic sysprefs are set |
| 225 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'homebranch'); |
226 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
| 226 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); |
227 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); |
| 227 |
|
228 |
|
| 228 |
# if IndependentBranches is OFF, a CPL patron can reserve an MPL item |
229 |
# if IndependentBranches is OFF, a CPL patron can reserve an MPL item |
|
Lines 422-427
CancelExpiredReserves();
Link Here
|
| 422 |
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id ); |
423 |
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id ); |
| 423 |
is( $count, 0, "Reserve with manual expiration date canceled correctly" ); |
424 |
is( $count, 0, "Reserve with manual expiration date canceled correctly" ); |
| 424 |
|
425 |
|
|
|
426 |
# Bug 12632 |
| 427 |
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 ); |
| 428 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); |
| 429 |
|
| 430 |
$dbh->do('DELETE FROM reserves'); |
| 431 |
$dbh->do('DELETE FROM issues'); |
| 432 |
$dbh->do('DELETE FROM items'); |
| 433 |
$dbh->do('DELETE FROM biblio'); |
| 434 |
|
| 435 |
( $bibnum, $title, $bibitemnum ) = create_helper_biblio('ONLY1'); |
| 436 |
( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( { homebranch => 'CPL', holdingbranch => 'CPL' }, $bibnum ); |
| 437 |
|
| 438 |
$dbh->do( |
| 439 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) |
| 440 |
VALUES (?, ?, ?, ?)}, |
| 441 |
{}, |
| 442 |
'*', '*', 'ONLY1', 1 |
| 443 |
); |
| 444 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ), |
| 445 |
'OK', 'Patron can reserve item with hold limit of 1, no holds placed' ); |
| 446 |
|
| 447 |
my $res_id = AddReserve( $branch, $borrowernumbers[0], $bibnum, 'a', '', 1, ); |
| 448 |
|
| 449 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ), |
| 450 |
'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' ); |
| 451 |
|
| 452 |
|
| 425 |
# Helper method to set up a Biblio. |
453 |
# Helper method to set up a Biblio. |
| 426 |
sub create_helper_biblio { |
454 |
sub create_helper_biblio { |
| 427 |
my $itemtype = shift; |
455 |
my $itemtype = shift; |
| 428 |
- |
|
|