Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use utf8; |
19 |
use utf8; |
20 |
|
20 |
|
21 |
use Test::More tests => 75; |
21 |
use Test::More tests => 76; |
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
24 |
use Test::Deep qw( cmp_deeply ); |
24 |
use Test::Deep qw( cmp_deeply ); |
Lines 2257-2262
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
2257 |
is( Koha::Account::Lines->search({ issue_id => $issue->id })->count, 1, 'UpdateFine should not create a new accountline when updating an existing fine'); |
2257 |
is( Koha::Account::Lines->search({ issue_id => $issue->id })->count, 1, 'UpdateFine should not create a new accountline when updating an existing fine'); |
2258 |
} |
2258 |
} |
2259 |
|
2259 |
|
|
|
2260 |
subtest "AllowRenewalIfOtherItemsAvailableLocation tests" => sub { |
2261 |
plan tests => 3; |
2262 |
|
2263 |
$dbh->do('DELETE FROM issues'); |
2264 |
$dbh->do('DELETE FROM items'); |
2265 |
$dbh->do('DELETE FROM circulation_rules'); |
2266 |
Koha::CirculationRules->set_rules( |
2267 |
{ |
2268 |
categorycode => undef, |
2269 |
itemtype => undef, |
2270 |
branchcode => undef, |
2271 |
rules => { |
2272 |
reservesallowed => 25, |
2273 |
issuelength => 14, |
2274 |
lengthunit => 'days', |
2275 |
renewalsallowed => 1, |
2276 |
renewalperiod => 7, |
2277 |
norenewalbefore => undef, |
2278 |
auto_renew => 0, |
2279 |
fine => .10, |
2280 |
chargeperiod => 1, |
2281 |
maxissueqty => 20, |
2282 |
onshelfholds => 1, |
2283 |
} |
2284 |
} |
2285 |
); |
2286 |
my $biblio = $builder->build_sample_biblio(); |
2287 |
|
2288 |
my $item_1 = $builder->build_sample_item( |
2289 |
{ |
2290 |
biblionumber => $biblio->biblionumber, |
2291 |
library => $library2->{branchcode}, |
2292 |
itype => $itemtype, |
2293 |
} |
2294 |
); |
2295 |
|
2296 |
# add second item with different branchcode |
2297 |
my $item_2 = $builder->build_sample_item( |
2298 |
{ |
2299 |
biblionumber => $biblio->biblionumber, |
2300 |
library => $library->{branchcode}, |
2301 |
itype => $itemtype, |
2302 |
} |
2303 |
); |
2304 |
|
2305 |
my $borrower1 = Koha::Patron->new( |
2306 |
{ |
2307 |
firstname => 'Kyle', |
2308 |
surname => 'Hall', |
2309 |
categorycode => $patron_category->{categorycode}, |
2310 |
branchcode => $library2->{branchcode}, |
2311 |
} |
2312 |
)->store; |
2313 |
my $borrowernumber1 = $borrower1->id; |
2314 |
my $borrower2 = Koha::Patron->new( |
2315 |
{ |
2316 |
firstname => 'Chelsea', |
2317 |
surname => 'Hall', |
2318 |
categorycode => $patron_category->{categorycode}, |
2319 |
branchcode => $library2->{branchcode}, |
2320 |
} |
2321 |
)->store; |
2322 |
my $borrowernumber2 = $borrower2->id; |
2323 |
|
2324 |
my $issue = AddIssue( $borrower1, $item_1->barcode ); |
2325 |
|
2326 |
# place bib-level reserve |
2327 |
AddReserve( |
2328 |
{ |
2329 |
branchcode => $library2->{branchcode}, |
2330 |
borrowernumber => $borrowernumber2, |
2331 |
biblionumber => $biblio->biblionumber, |
2332 |
priority => 1, |
2333 |
} |
2334 |
); |
2335 |
|
2336 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
2337 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'any' ); |
2338 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
2339 |
is( $renewokay, 1, 'Renewal allowed if items available at any branch' ); |
2340 |
|
2341 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'holdbranch' ); |
2342 |
( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
2343 |
is( $renewokay, 0, 'Renewal not allowed as available item is at a different branch' ); |
2344 |
|
2345 |
# adjust 2nd item to have same branchcode |
2346 |
$item_2->update( { homebranch => $library2->{branchcode}, holdingbranch => $library2->{branchcode} } )->store; |
2347 |
( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
2348 |
is( $renewokay, 1, 'Renewal allowed if items available at hold branch' ); |
2349 |
}; |
2350 |
|
2260 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
2351 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
2261 |
plan tests => 24; |
2352 |
plan tests => 24; |
2262 |
|
2353 |
|
2263 |
- |
|
|