|
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 => 41; |
| 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 56-63
foreach (1..$borrowers_count) {
Link Here
|
| 56 |
|
56 |
|
| 57 |
my $biblionumber = $bibnum; |
57 |
my $biblionumber = $bibnum; |
| 58 |
|
58 |
|
| 59 |
my @branches = GetBranchesLoop(); |
59 |
my $branches = GetBranchesLoop(); |
| 60 |
my $branch = $branches[0][0]{value}; |
60 |
my $branch = $branches->[0]{value}; |
| 61 |
|
61 |
|
| 62 |
# Create five item level holds |
62 |
# Create five item level holds |
| 63 |
foreach my $borrowernumber ( @borrowernumbers ) { |
63 |
foreach my $borrowernumber ( @borrowernumbers ) { |
|
Lines 205-211
$dbh->do(
Link Here
|
| 205 |
); |
205 |
); |
| 206 |
|
206 |
|
| 207 |
# make sure some basic sysprefs are set |
207 |
# make sure some basic sysprefs are set |
| 208 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'homebranch'); |
208 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
| 209 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); |
209 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); |
| 210 |
|
210 |
|
| 211 |
# if IndependentBranches is OFF, a CPL patron can reserve an MPL item |
211 |
# if IndependentBranches is OFF, a CPL patron can reserve an MPL item |
|
Lines 293-302
ModReserve({ reserve_id => $reserveid2, rank => 'del' });
Link Here
|
| 293 |
$reserve3 = GetReserve( $reserveid3 ); |
293 |
$reserve3 = GetReserve( $reserveid3 ); |
| 294 |
is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); |
294 |
is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); |
| 295 |
|
295 |
|
|
|
296 |
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); |
| 297 |
|
| 296 |
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); |
298 |
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); |
|
|
299 |
CancelReserve({reserve_id => $reserveid3}); |
| 297 |
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 1 ); |
300 |
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 1 ); |
| 298 |
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); |
301 |
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); |
| 299 |
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); |
|
|
| 300 |
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 0 ); |
302 |
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 0 ); |
| 301 |
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'damaged', "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" ); |
303 |
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'damaged', "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" ); |
| 302 |
ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for damaged item with AllowHoldsOnDamagedItems disabled" ); |
304 |
ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for damaged item with AllowHoldsOnDamagedItems disabled" ); |
|
Lines 312-334
AddReserve(
Link Here
|
| 312 |
'', |
314 |
'', |
| 313 |
1, |
315 |
1, |
| 314 |
); |
316 |
); |
|
|
317 |
my ($bibnum2, $title2, $bibitemnum2) = create_helper_biblio('CANNOT'); |
| 318 |
my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => $branch, holdingbranch => $branch, itype => 'CANNOT' } , $bibnum2); |
| 315 |
ok( |
319 |
ok( |
| 316 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'tooManyReserves', |
320 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2) eq 'tooManyReserves', |
| 317 |
"cannot request item if policy that matches on item-level item type forbids it" |
321 |
"cannot request item if policy that matches on item-level item type forbids it" |
| 318 |
); |
322 |
); |
| 319 |
ModItem({ itype => 'CAN' }, $item_bibnum, $itemnumber); |
323 |
ModItem({ itype => 'CAN' }, $item_bibnum2, $itemnumber2); |
| 320 |
ok( |
324 |
ok( |
| 321 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'OK', |
325 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2) eq 'OK', |
| 322 |
"can request item if policy that matches on item type allows it" |
326 |
"can request item if policy that matches on item type allows it" |
| 323 |
); |
327 |
); |
| 324 |
|
328 |
|
| 325 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
329 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
| 326 |
ModItem({ itype => undef }, $item_bibnum, $itemnumber); |
330 |
ModItem({ itype => undef }, $item_bibnum2, $itemnumber2); |
| 327 |
ok( |
331 |
ok( |
| 328 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'tooManyReserves', |
332 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2) eq 'tooManyReserves', |
| 329 |
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" |
333 |
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" |
| 330 |
); |
334 |
); |
| 331 |
|
335 |
|
|
|
336 |
is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'alreadyReserved'); |
| 337 |
|
| 338 |
C4::Context->set_preference('maxreserves', 1); |
| 339 |
ok(CanBookBeReserved($borrowernumbers[0], $biblionumber) eq 'tooManyReserves'); |
| 340 |
|
| 341 |
C4::Context->set_preference('maxreserves', 0); |
| 342 |
t::lib::Mocks::mock_preference('IndependentBranches', 1); |
| 343 |
t::lib::Mocks::mock_preference('canreservefromotherbranches', 0); |
| 344 |
ok(CanBookBeReserved($borrowernumbers[0], $foreign_bibnum) eq 'none_available'); |
| 345 |
|
| 332 |
# Test CancelExpiredReserves |
346 |
# Test CancelExpiredReserves |
| 333 |
C4::Context->set_preference('ExpireReservesMaxPickUpDelay', 1); |
347 |
C4::Context->set_preference('ExpireReservesMaxPickUpDelay', 1); |
| 334 |
C4::Context->set_preference('ReservesMaxPickUpDelay', 1); |
348 |
C4::Context->set_preference('ReservesMaxPickUpDelay', 1); |
|
Lines 370-379
sub create_helper_biblio {
Link Here
|
| 370 |
my $itemtype = shift; |
384 |
my $itemtype = shift; |
| 371 |
my $bib = MARC::Record->new(); |
385 |
my $bib = MARC::Record->new(); |
| 372 |
my $title = 'Silence in the library'; |
386 |
my $title = 'Silence in the library'; |
| 373 |
$bib->append_fields( |
387 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
| 374 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
388 |
$bib->append_fields( |
| 375 |
MARC::Field->new('245', ' ', ' ', a => $title), |
389 |
MARC::Field->new('700', ' ', '0', a => 'Moffat, Steven'), |
| 376 |
MARC::Field->new('942', ' ', ' ', c => $itemtype), |
390 |
MARC::Field->new('200', ' ', ' ', a => $title), |
| 377 |
); |
391 |
MARC::Field->new('099', ' ', ' ', t => $itemtype), |
| 378 |
return ($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); |
392 |
); |
|
|
393 |
} else { |
| 394 |
$bib->append_fields( |
| 395 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
| 396 |
MARC::Field->new('245', ' ', ' ', a => $title), |
| 397 |
MARC::Field->new('942', ' ', ' ', c => $itemtype), |
| 398 |
); |
| 399 |
} |
| 400 |
|
| 401 |
return AddBiblio($bib, ''); |
| 379 |
} |
402 |
} |
| 380 |
- |
|
|