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 => 53; |
21 |
use Test::More tests => 54; |
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 282-287
Koha::CirculationRules->set_rules(
Link Here
|
282 |
} |
282 |
} |
283 |
); |
283 |
); |
284 |
|
284 |
|
|
|
285 |
subtest "CanBookBeRenewed AllowRenewalIfOtherItemsAvailable multiple borrowers and items tests" => sub { |
286 |
plan tests => 5; |
287 |
|
288 |
#Can only reserve from home branch |
289 |
Koha::CirculationRules->set_rule( |
290 |
{ |
291 |
branchcode => undef, |
292 |
itemtype => undef, |
293 |
rule_name => 'holdallowed', |
294 |
rule_value => 1 |
295 |
} |
296 |
); |
297 |
Koha::CirculationRules->set_rule( |
298 |
{ |
299 |
branchcode => undef, |
300 |
categorycode => undef, |
301 |
itemtype => undef, |
302 |
rule_name => 'onshelfholds', |
303 |
rule_value => 1 |
304 |
} |
305 |
); |
306 |
|
307 |
# Patrons from three different branches |
308 |
my $patron_borrower = $builder->build_object({ class => 'Koha::Patrons' }); |
309 |
my $patron_hold_1 = $builder->build_object({ class => 'Koha::Patrons' }); |
310 |
my $patron_hold_2 = $builder->build_object({ class => 'Koha::Patrons' }); |
311 |
my $biblio = $builder->build_sample_biblio(); |
312 |
|
313 |
# Item at each patron branch |
314 |
my $item_1 = $builder->build_sample_item({ |
315 |
biblionumber => $biblio->biblionumber, |
316 |
homebranch => $patron_borrower->branchcode |
317 |
}); |
318 |
my $item_2 = $builder->build_sample_item({ |
319 |
biblionumber => $biblio->biblionumber, |
320 |
homebranch => $patron_hold_2->branchcode |
321 |
}); |
322 |
my $item_3 = $builder->build_sample_item({ |
323 |
biblionumber => $biblio->biblionumber, |
324 |
homebranch => $patron_hold_1->branchcode |
325 |
}); |
326 |
|
327 |
my $issue = AddIssue( $patron_borrower->unblessed, $item_1->barcode); |
328 |
my $datedue = dt_from_string( $issue->date_due() ); |
329 |
is (defined $issue->date_due(), 1, "Item 1 checked out, due date: " . $issue->date_due() ); |
330 |
|
331 |
# Biblio-level holds |
332 |
AddReserve( |
333 |
{ |
334 |
branchcode => $patron_hold_1->branchcode, |
335 |
borrowernumber => $patron_hold_1->borrowernumber, |
336 |
biblionumber => $biblio->biblionumber, |
337 |
priority => 1, |
338 |
reservation_date => dt_from_string(), |
339 |
expiration_date => undef, |
340 |
itemnumber => undef, |
341 |
found => undef, |
342 |
} |
343 |
); |
344 |
AddReserve( |
345 |
{ |
346 |
branchcode => $patron_hold_2->branchcode, |
347 |
borrowernumber => $patron_hold_2->borrowernumber, |
348 |
biblionumber => $biblio->biblionumber, |
349 |
priority => 2, |
350 |
reservation_date => dt_from_string(), |
351 |
expiration_date => undef, |
352 |
itemnumber => undef, |
353 |
found => undef, |
354 |
} |
355 |
); |
356 |
t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 0 ); |
357 |
|
358 |
my ( $renewokay, $error ) = CanBookBeRenewed($patron_borrower->borrowernumber, $item_1->itemnumber); |
359 |
is( $renewokay, 0, 'Cannot renew, reserved'); |
360 |
is( $error, 'on_reserve', 'Cannot renew, reserved (returned error is on_reserve)'); |
361 |
|
362 |
t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); |
363 |
|
364 |
( $renewokay, $error ) = CanBookBeRenewed($patron_borrower->borrowernumber, $item_1->itemnumber); |
365 |
is( $renewokay, 1, 'Can renew, two items available for two holds'); |
366 |
is( $error, undef, 'Can renew, each reserve has an item'); |
367 |
|
368 |
|
369 |
}; |
370 |
|
285 |
subtest "GetIssuingCharges tests" => sub { |
371 |
subtest "GetIssuingCharges tests" => sub { |
286 |
plan tests => 4; |
372 |
plan tests => 4; |
287 |
my $branch_discount = $builder->build_object({ class => 'Koha::Libraries' }); |
373 |
my $branch_discount = $builder->build_object({ class => 'Koha::Libraries' }); |
288 |
- |
|
|