|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
use utf8; |
19 |
use utf8; |
| 20 |
|
20 |
|
| 21 |
use Test::NoWarnings; |
21 |
use Test::NoWarnings; |
| 22 |
use Test::More tests => 84; |
22 |
use Test::More tests => 85; |
| 23 |
use Test::Exception; |
23 |
use Test::Exception; |
| 24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
| 25 |
use Test::Deep qw( cmp_deeply ); |
25 |
use Test::Deep qw( cmp_deeply ); |
|
Lines 2455-2460
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
| 2455 |
); |
2455 |
); |
| 2456 |
} |
2456 |
} |
| 2457 |
|
2457 |
|
|
|
2458 |
subtest "AllowRenewalIfOtherItemsAvailableLocation tests" => sub { |
| 2459 |
plan tests => 3; |
| 2460 |
|
| 2461 |
$dbh->do('DELETE FROM issues'); |
| 2462 |
$dbh->do('DELETE FROM items'); |
| 2463 |
$dbh->do('DELETE FROM circulation_rules'); |
| 2464 |
Koha::CirculationRules->set_rules( |
| 2465 |
{ |
| 2466 |
categorycode => undef, |
| 2467 |
itemtype => undef, |
| 2468 |
branchcode => undef, |
| 2469 |
rules => { |
| 2470 |
reservesallowed => 25, |
| 2471 |
issuelength => 14, |
| 2472 |
lengthunit => 'days', |
| 2473 |
renewalsallowed => 1, |
| 2474 |
renewalperiod => 7, |
| 2475 |
norenewalbefore => undef, |
| 2476 |
auto_renew => 0, |
| 2477 |
fine => .10, |
| 2478 |
chargeperiod => 1, |
| 2479 |
maxissueqty => 20, |
| 2480 |
onshelfholds => 1, |
| 2481 |
} |
| 2482 |
} |
| 2483 |
); |
| 2484 |
my $biblio = $builder->build_sample_biblio(); |
| 2485 |
|
| 2486 |
my $item_1 = $builder->build_sample_item( |
| 2487 |
{ |
| 2488 |
biblionumber => $biblio->biblionumber, |
| 2489 |
library => $library2->{branchcode}, |
| 2490 |
itype => $itemtype, |
| 2491 |
} |
| 2492 |
); |
| 2493 |
|
| 2494 |
# add second item with different branchcode |
| 2495 |
my $item_2 = $builder->build_sample_item( |
| 2496 |
{ |
| 2497 |
biblionumber => $biblio->biblionumber, |
| 2498 |
library => $library->{branchcode}, |
| 2499 |
itype => $itemtype, |
| 2500 |
} |
| 2501 |
); |
| 2502 |
|
| 2503 |
my $borrower1 = Koha::Patron->new( |
| 2504 |
{ |
| 2505 |
firstname => 'Kyle', |
| 2506 |
surname => 'Hall', |
| 2507 |
categorycode => $patron_category->{categorycode}, |
| 2508 |
branchcode => $library2->{branchcode}, |
| 2509 |
} |
| 2510 |
)->store; |
| 2511 |
my $borrowernumber1 = $borrower1->id; |
| 2512 |
my $borrower2 = Koha::Patron->new( |
| 2513 |
{ |
| 2514 |
firstname => 'Chelsea', |
| 2515 |
surname => 'Hall', |
| 2516 |
categorycode => $patron_category->{categorycode}, |
| 2517 |
branchcode => $library2->{branchcode}, |
| 2518 |
} |
| 2519 |
)->store; |
| 2520 |
my $borrowernumber2 = $borrower2->id; |
| 2521 |
|
| 2522 |
my $issue = AddIssue( $borrower1, $item_1->barcode ); |
| 2523 |
|
| 2524 |
# place bib-level reserve |
| 2525 |
AddReserve( |
| 2526 |
{ |
| 2527 |
branchcode => $library2->{branchcode}, |
| 2528 |
borrowernumber => $borrowernumber2, |
| 2529 |
biblionumber => $biblio->biblionumber, |
| 2530 |
priority => 1, |
| 2531 |
} |
| 2532 |
); |
| 2533 |
|
| 2534 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
| 2535 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'any' ); |
| 2536 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
| 2537 |
is( $renewokay, 1, 'Renewal allowed if items available at any branch' ); |
| 2538 |
|
| 2539 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'holdbranch' ); |
| 2540 |
( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
| 2541 |
is( $renewokay, 0, 'Renewal not allowed as available item is at a different branch' ); |
| 2542 |
|
| 2543 |
# adjust 2nd item to have same branchcode |
| 2544 |
$item_2->update( { homebranch => $library2->{branchcode}, holdingbranch => $library2->{branchcode} } )->store; |
| 2545 |
( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
| 2546 |
is( $renewokay, 1, 'Renewal allowed if items available at hold branch' ); |
| 2547 |
}; |
| 2548 |
|
| 2458 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
2549 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
| 2459 |
plan tests => 27; |
2550 |
plan tests => 27; |
| 2460 |
|
2551 |
|
| 2461 |
- |
|
|