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 => 61; |
10 |
use Test::More tests => 64; |
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 334-343
ModReserve({ reserve_id => $reserveid2, rank => 'del' });
Link Here
|
334 |
$reserve3 = GetReserve( $reserveid3 ); |
334 |
$reserve3 = GetReserve( $reserveid3 ); |
335 |
is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); |
335 |
is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); |
336 |
|
336 |
|
|
|
337 |
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); |
338 |
|
337 |
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); |
339 |
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); |
|
|
340 |
CancelReserve({reserve_id => $reserveid3}); |
338 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 ); |
341 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 ); |
339 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); |
342 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); |
340 |
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); |
|
|
341 |
|
343 |
|
342 |
$hold = Koha::Hold->new( |
344 |
$hold = Koha::Hold->new( |
343 |
{ |
345 |
{ |
Lines 365-387
AddReserve(
Link Here
|
365 |
'', |
367 |
'', |
366 |
1, |
368 |
1, |
367 |
); |
369 |
); |
|
|
370 |
my ($bibnum2, $title2, $bibitemnum2) = create_helper_biblio('CANNOT'); |
371 |
my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $bibnum2); |
368 |
is( |
372 |
is( |
369 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'tooManyReserves', |
373 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2), 'tooManyReserves', |
370 |
"cannot request item if policy that matches on item-level item type forbids it" |
374 |
"cannot request item if policy that matches on item-level item type forbids it" |
371 |
); |
375 |
); |
372 |
ModItem({ itype => 'CAN' }, $item_bibnum, $itemnumber); |
376 |
ModItem({ itype => 'CAN' }, $item_bibnum2, $itemnumber2); |
373 |
ok( |
377 |
ok( |
374 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'OK', |
378 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2) eq 'OK', |
375 |
"can request item if policy that matches on item type allows it" |
379 |
"can request item if policy that matches on item type allows it" |
376 |
); |
380 |
); |
377 |
|
381 |
|
378 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
382 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
379 |
ModItem({ itype => undef }, $item_bibnum, $itemnumber); |
383 |
ModItem({ itype => undef }, $item_bibnum2, $itemnumber2); |
380 |
ok( |
384 |
ok( |
381 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'tooManyReserves', |
385 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2) eq 'tooManyReserves', |
382 |
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" |
386 |
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" |
383 |
); |
387 |
); |
384 |
|
388 |
|
|
|
389 |
is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'alreadyReserved'); |
390 |
|
391 |
C4::Context->set_preference('maxreserves', 1); |
392 |
ok(CanBookBeReserved($borrowernumbers[0], $biblionumber) eq 'tooManyReserves'); |
393 |
|
394 |
C4::Context->set_preference('maxreserves', 0); |
395 |
t::lib::Mocks::mock_preference('IndependentBranches', 1); |
396 |
t::lib::Mocks::mock_preference('canreservefromotherbranches', 0); |
397 |
ok(CanBookBeReserved($borrowernumbers[0], $foreign_bibnum) eq 'none_available'); |
385 |
|
398 |
|
386 |
# Test branch item rules |
399 |
# Test branch item rules |
387 |
|
400 |
|
Lines 491-500
sub create_helper_biblio {
Link Here
|
491 |
my $itemtype = shift; |
504 |
my $itemtype = shift; |
492 |
my $bib = MARC::Record->new(); |
505 |
my $bib = MARC::Record->new(); |
493 |
my $title = 'Silence in the library'; |
506 |
my $title = 'Silence in the library'; |
494 |
$bib->append_fields( |
507 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
495 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
508 |
$bib->append_fields( |
496 |
MARC::Field->new('245', ' ', ' ', a => $title), |
509 |
MARC::Field->new('700', ' ', '0', a => 'Moffat, Steven'), |
497 |
MARC::Field->new('942', ' ', ' ', c => $itemtype), |
510 |
MARC::Field->new('200', ' ', ' ', a => $title), |
498 |
); |
511 |
MARC::Field->new('099', ' ', ' ', t => $itemtype), |
499 |
return ($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); |
512 |
); |
|
|
513 |
} else { |
514 |
$bib->append_fields( |
515 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
516 |
MARC::Field->new('245', ' ', ' ', a => $title), |
517 |
MARC::Field->new('942', ' ', ' ', c => $itemtype), |
518 |
); |
519 |
} |
520 |
|
521 |
return AddBiblio($bib, ''); |
500 |
} |
522 |
} |
501 |
- |
|
|