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 |
|
12 |
|
13 |
use C4::Biblio; |
13 |
use C4::Biblio; |
Lines 299-305
ok(
Link Here
|
299 |
is( $hold3->discard_changes->priority, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); |
299 |
is( $hold3->discard_changes->priority, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); |
300 |
} |
300 |
} |
301 |
|
301 |
|
|
|
302 |
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); |
303 |
|
302 |
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); |
304 |
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); |
|
|
305 |
CancelReserve({reserve_id => $reserveid3}); |
303 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 ); |
306 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 ); |
304 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); |
307 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); |
305 |
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); |
308 |
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); |
Lines 330-352
AddReserve(
Link Here
|
330 |
'', |
333 |
'', |
331 |
1, |
334 |
1, |
332 |
); |
335 |
); |
|
|
336 |
my ($bibnum2, $title2, $bibitemnum2) = create_helper_biblio('CANNOT'); |
337 |
my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $bibnum2); |
333 |
is( |
338 |
is( |
|
|
339 |
<<<<<<< HEAD |
334 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'tooManyReserves', |
340 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'tooManyReserves', |
|
|
341 |
======= |
342 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2), 'tooManyReserves', |
343 |
>>>>>>> Bug 11999: Add two checks in CanBookBeReserved and CanItemBeReserved |
335 |
"cannot request item if policy that matches on item-level item type forbids it" |
344 |
"cannot request item if policy that matches on item-level item type forbids it" |
336 |
); |
345 |
); |
337 |
ModItem({ itype => 'CAN' }, $item_bibnum, $itemnumber); |
346 |
ModItem({ itype => 'CAN' }, $item_bibnum2, $itemnumber2); |
338 |
ok( |
347 |
ok( |
|
|
348 |
<<<<<<< HEAD |
339 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status} eq 'OK', |
349 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status} eq 'OK', |
|
|
350 |
======= |
351 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2) eq 'OK', |
352 |
>>>>>>> Bug 11999: Add two checks in CanBookBeReserved and CanItemBeReserved |
340 |
"can request item if policy that matches on item type allows it" |
353 |
"can request item if policy that matches on item type allows it" |
341 |
); |
354 |
); |
342 |
|
355 |
|
343 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
356 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
|
|
357 |
<<<<<<< HEAD |
344 |
ModItem({ itype => undef }, $item_bibnum, $itemnumber); |
358 |
ModItem({ itype => undef }, $item_bibnum, $itemnumber); |
345 |
ok( |
359 |
ok( |
346 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status} eq 'tooManyReserves', |
360 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status} eq 'tooManyReserves', |
|
|
361 |
======= |
362 |
ModItem({ itype => undef }, $item_bibnum2, $itemnumber2); |
363 |
is( |
364 |
CanItemBeReserved( $borrowernumbers[0], $itemnumber2), 'tooManyReserves', |
365 |
>>>>>>> Bug 11999: Add two checks in CanBookBeReserved and CanItemBeReserved |
347 |
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" |
366 |
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" |
348 |
); |
367 |
); |
349 |
|
368 |
|
|
|
369 |
is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'OK'); |
370 |
|
371 |
C4::Context->set_preference('maxreserves', 1); |
372 |
ok(CanBookBeReserved($borrowernumbers[0], $biblionumber) eq 'tooManyReserves'); |
373 |
|
374 |
C4::Context->set_preference('maxreserves', 0); |
375 |
t::lib::Mocks::mock_preference('IndependentBranches', 1); |
376 |
t::lib::Mocks::mock_preference('canreservefromotherbranches', 0); |
377 |
ok(CanBookBeReserved($borrowernumbers[0], $foreign_bibnum) eq 'none_available'); |
350 |
|
378 |
|
351 |
# Test branch item rules |
379 |
# Test branch item rules |
352 |
|
380 |
|
Lines 410-417
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber )->{status},
Link Here
|
410 |
|
438 |
|
411 |
my $res_id = AddReserve( $branch_1, $borrowernumbers[0], $biblio->biblionumber, '', 1, ); |
439 |
my $res_id = AddReserve( $branch_1, $borrowernumbers[0], $biblio->biblionumber, '', 1, ); |
412 |
|
440 |
|
|
|
441 |
<<<<<<< HEAD |
413 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber )->{status}, |
442 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber )->{status}, |
414 |
'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' ); |
443 |
'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' ); |
|
|
444 |
======= |
445 |
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ), |
446 |
'tooManyHoldsForThisRecord', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' ); |
447 |
>>>>>>> Bug 11999: Add two checks in CanBookBeReserved and CanItemBeReserved |
415 |
|
448 |
|
416 |
#results should be the same for both ReservesControlBranch settings |
449 |
#results should be the same for both ReservesControlBranch settings |
417 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); |
450 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); |
Lines 420-425
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber )->{status},
Link Here
|
420 |
#reset for further tests |
453 |
#reset for further tests |
421 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); |
454 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); |
422 |
|
455 |
|
|
|
456 |
<<<<<<< HEAD |
423 |
subtest 'Test max_holds per library/patron category' => sub { |
457 |
subtest 'Test max_holds per library/patron category' => sub { |
424 |
plan tests => 6; |
458 |
plan tests => 6; |
425 |
|
459 |
|
Lines 670-672
subtest 'CanItemBeReserved / holds_per_day tests' => sub {
Link Here
|
670 |
|
704 |
|
671 |
$schema->storage->txn_rollback; |
705 |
$schema->storage->txn_rollback; |
672 |
}; |
706 |
}; |
673 |
- |
707 |
======= |
|
|
708 |
# Helper method to set up a Biblio. |
709 |
sub create_helper_biblio { |
710 |
my $itemtype = shift; |
711 |
my $bib = MARC::Record->new(); |
712 |
my $title = 'Silence in the library'; |
713 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
714 |
$bib->append_fields( |
715 |
MARC::Field->new('700', ' ', '0', a => 'Moffat, Steven'), |
716 |
MARC::Field->new('200', ' ', ' ', a => $title), |
717 |
MARC::Field->new('099', ' ', ' ', t => $itemtype), |
718 |
); |
719 |
} else { |
720 |
$bib->append_fields( |
721 |
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), |
722 |
MARC::Field->new('245', ' ', ' ', a => $title), |
723 |
MARC::Field->new('942', ' ', ' ', c => $itemtype), |
724 |
); |
725 |
} |
726 |
|
727 |
return AddBiblio($bib, ''); |
728 |
} |
729 |
>>>>>>> Bug 11999: Add two checks in CanBookBeReserved and CanItemBeReserved |