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 => 58; |
10 |
use Test::More tests => 61; |
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 345-354
ModReserve({ reserve_id => $reserveid2, rank => 'del' });
Link Here
|
345 |
$reserve3 = GetReserve( $reserveid3 ); |
345 |
$reserve3 = GetReserve( $reserveid3 ); |
346 |
is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); |
346 |
is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); |
347 |
|
347 |
|
|
|
348 |
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); |
349 |
|
348 |
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); |
350 |
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); |
|
|
351 |
CancelReserve({reserve_id => $reserveid3}); |
349 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 ); |
352 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 ); |
350 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); |
353 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); |
351 |
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); |
|
|
352 |
|
354 |
|
353 |
$hold = Koha::Hold->new( |
355 |
$hold = Koha::Hold->new( |
354 |
{ |
356 |
{ |
Lines 376-398
AddReserve(
Link Here
|
376 |
'', |
378 |
'', |
377 |
1, |
379 |
1, |
378 |
); |
380 |
); |
|
|
381 |
my ($bibnum2, $title2, $bibitemnum2) = create_helper_biblio('CANNOT'); |
382 |
my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $bibnum2); |
379 |
is( |
383 |
is( |
380 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'tooManyReserves', |
384 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2), 'tooManyReserves', |
381 |
"cannot request item if policy that matches on item-level item type forbids it" |
385 |
"cannot request item if policy that matches on item-level item type forbids it" |
382 |
); |
386 |
); |
383 |
ModItem({ itype => 'CAN' }, $item_bibnum, $itemnumber); |
387 |
ModItem({ itype => 'CAN' }, $item_bibnum2, $itemnumber2); |
384 |
ok( |
388 |
ok( |
385 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'OK', |
389 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2) eq 'OK', |
386 |
"can request item if policy that matches on item type allows it" |
390 |
"can request item if policy that matches on item type allows it" |
387 |
); |
391 |
); |
388 |
|
392 |
|
389 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
393 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
390 |
ModItem({ itype => undef }, $item_bibnum, $itemnumber); |
394 |
ModItem({ itype => undef }, $item_bibnum2, $itemnumber2); |
391 |
ok( |
395 |
ok( |
392 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'tooManyReserves', |
396 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2) eq 'tooManyReserves', |
393 |
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" |
397 |
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" |
394 |
); |
398 |
); |
395 |
|
399 |
|
|
|
400 |
is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'alreadyReserved'); |
401 |
|
402 |
C4::Context->set_preference('maxreserves', 1); |
403 |
ok(CanBookBeReserved($borrowernumbers[0], $biblionumber) eq 'tooManyReserves'); |
404 |
|
405 |
C4::Context->set_preference('maxreserves', 0); |
406 |
t::lib::Mocks::mock_preference('IndependentBranches', 1); |
407 |
t::lib::Mocks::mock_preference('canreservefromotherbranches', 0); |
408 |
ok(CanBookBeReserved($borrowernumbers[0], $foreign_bibnum) eq 'none_available'); |
396 |
|
409 |
|
397 |
# Test branch item rules |
410 |
# Test branch item rules |
398 |
|
411 |
|
Lines 465-474
sub create_helper_biblio {
Link Here
|
465 |
my $itemtype = shift; |
478 |
my $itemtype = shift; |
466 |
my $bib = MARC::Record->new(); |
479 |
my $bib = MARC::Record->new(); |
467 |
my $title = 'Silence in the library'; |
480 |
my $title = 'Silence in the library'; |
468 |
$bib->append_fields( |
481 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
469 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
482 |
$bib->append_fields( |
470 |
MARC::Field->new('245', ' ', ' ', a => $title), |
483 |
MARC::Field->new('700', ' ', '0', a => 'Moffat, Steven'), |
471 |
MARC::Field->new('942', ' ', ' ', c => $itemtype), |
484 |
MARC::Field->new('200', ' ', ' ', a => $title), |
472 |
); |
485 |
MARC::Field->new('099', ' ', ' ', t => $itemtype), |
473 |
return ($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); |
486 |
); |
|
|
487 |
} else { |
488 |
$bib->append_fields( |
489 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
490 |
MARC::Field->new('245', ' ', ' ', a => $title), |
491 |
MARC::Field->new('942', ' ', ' ', c => $itemtype), |
492 |
); |
493 |
} |
494 |
|
495 |
return AddBiblio($bib, ''); |
474 |
} |
496 |
} |
475 |
- |
|
|