|
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 => 82; |
22 |
use Test::More tests => 83; |
| 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 2402-2407
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
| 2402 |
); |
2402 |
); |
| 2403 |
} |
2403 |
} |
| 2404 |
|
2404 |
|
|
|
2405 |
subtest "AllowRenewalIfOtherItemsAvailableLocation tests" => sub { |
| 2406 |
plan tests => 3; |
| 2407 |
|
| 2408 |
$dbh->do('DELETE FROM issues'); |
| 2409 |
$dbh->do('DELETE FROM items'); |
| 2410 |
$dbh->do('DELETE FROM circulation_rules'); |
| 2411 |
Koha::CirculationRules->set_rules( |
| 2412 |
{ |
| 2413 |
categorycode => undef, |
| 2414 |
itemtype => undef, |
| 2415 |
branchcode => undef, |
| 2416 |
rules => { |
| 2417 |
reservesallowed => 25, |
| 2418 |
issuelength => 14, |
| 2419 |
lengthunit => 'days', |
| 2420 |
renewalsallowed => 1, |
| 2421 |
renewalperiod => 7, |
| 2422 |
norenewalbefore => undef, |
| 2423 |
auto_renew => 0, |
| 2424 |
fine => .10, |
| 2425 |
chargeperiod => 1, |
| 2426 |
maxissueqty => 20, |
| 2427 |
onshelfholds => 1, |
| 2428 |
} |
| 2429 |
} |
| 2430 |
); |
| 2431 |
my $biblio = $builder->build_sample_biblio(); |
| 2432 |
|
| 2433 |
my $item_1 = $builder->build_sample_item( |
| 2434 |
{ |
| 2435 |
biblionumber => $biblio->biblionumber, |
| 2436 |
library => $library2->{branchcode}, |
| 2437 |
itype => $itemtype, |
| 2438 |
} |
| 2439 |
); |
| 2440 |
|
| 2441 |
# add second item with different branchcode |
| 2442 |
my $item_2 = $builder->build_sample_item( |
| 2443 |
{ |
| 2444 |
biblionumber => $biblio->biblionumber, |
| 2445 |
library => $library->{branchcode}, |
| 2446 |
itype => $itemtype, |
| 2447 |
} |
| 2448 |
); |
| 2449 |
|
| 2450 |
my $borrower1 = Koha::Patron->new( |
| 2451 |
{ |
| 2452 |
firstname => 'Kyle', |
| 2453 |
surname => 'Hall', |
| 2454 |
categorycode => $patron_category->{categorycode}, |
| 2455 |
branchcode => $library2->{branchcode}, |
| 2456 |
} |
| 2457 |
)->store; |
| 2458 |
my $borrowernumber1 = $borrower1->id; |
| 2459 |
my $borrower2 = Koha::Patron->new( |
| 2460 |
{ |
| 2461 |
firstname => 'Chelsea', |
| 2462 |
surname => 'Hall', |
| 2463 |
categorycode => $patron_category->{categorycode}, |
| 2464 |
branchcode => $library2->{branchcode}, |
| 2465 |
} |
| 2466 |
)->store; |
| 2467 |
my $borrowernumber2 = $borrower2->id; |
| 2468 |
|
| 2469 |
my $issue = AddIssue( $borrower1, $item_1->barcode ); |
| 2470 |
|
| 2471 |
# place bib-level reserve |
| 2472 |
AddReserve( |
| 2473 |
{ |
| 2474 |
branchcode => $library2->{branchcode}, |
| 2475 |
borrowernumber => $borrowernumber2, |
| 2476 |
biblionumber => $biblio->biblionumber, |
| 2477 |
priority => 1, |
| 2478 |
} |
| 2479 |
); |
| 2480 |
|
| 2481 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
| 2482 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'any' ); |
| 2483 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
| 2484 |
is( $renewokay, 1, 'Renewal allowed if items available at any branch' ); |
| 2485 |
|
| 2486 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'holdbranch' ); |
| 2487 |
( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
| 2488 |
is( $renewokay, 0, 'Renewal not allowed as available item is at a different branch' ); |
| 2489 |
|
| 2490 |
# adjust 2nd item to have same branchcode |
| 2491 |
$item_2->update( { homebranch => $library2->{branchcode}, holdingbranch => $library2->{branchcode} } )->store; |
| 2492 |
( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
| 2493 |
is( $renewokay, 1, 'Renewal allowed if items available at hold branch' ); |
| 2494 |
}; |
| 2495 |
|
| 2405 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
2496 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
| 2406 |
plan tests => 27; |
2497 |
plan tests => 27; |
| 2407 |
|
2498 |
|
| 2408 |
- |
|
|