|
Lines 8-14
use C4::Items;
Link Here
|
| 8 |
use Koha::Items; |
8 |
use Koha::Items; |
| 9 |
use Koha::CirculationRules; |
9 |
use Koha::CirculationRules; |
| 10 |
|
10 |
|
| 11 |
use Test::More tests => 10; |
11 |
use Test::More tests => 12; |
| 12 |
|
12 |
|
| 13 |
use t::lib::TestBuilder; |
13 |
use t::lib::TestBuilder; |
| 14 |
use t::lib::Mocks; |
14 |
use t::lib::Mocks; |
|
Lines 285-290
is( $is, 1, "Items availability: 1 item is available, 1 item held in T" );
Link Here
|
| 285 |
$is = IsAvailableForItemLevelRequest( $item3, $patron1); |
285 |
$is = IsAvailableForItemLevelRequest( $item3, $patron1); |
| 286 |
is( $is, 1, "Item can be held, items in transit are not available" ); |
286 |
is( $is, 1, "Item can be held, items in transit are not available" ); |
| 287 |
|
287 |
|
|
|
288 |
|
| 289 |
# Check for holds availability when different item types have different |
| 290 |
# smart rules assigned both with "if all unavailable" set, |
| 291 |
# and $itemtype rule allows holds, $itemtype2 rule disallows holds. |
| 292 |
# So, $item should be available for hold when checked out even if $item2 |
| 293 |
# is not checked out, because anyway $item2 unavailable for holds by rule |
| 294 |
# (Bug 24683): |
| 295 |
|
| 296 |
my $biblio1 = $builder->build_sample_biblio({itemtype=>$itemtype}); |
| 297 |
my $biblionumber1 = $biblio1->biblionumber; |
| 298 |
my $item1_1 = $builder->build_sample_item({ |
| 299 |
biblionumber=>$biblionumber1, |
| 300 |
itype=>$itemtype, |
| 301 |
homebranch => $library_A, |
| 302 |
holdingbranch => $library_A |
| 303 |
}); |
| 304 |
my $item1_2 = $builder->build_sample_item({ |
| 305 |
biblionumber=>$biblionumber1, |
| 306 |
itype=>$itemtype2, |
| 307 |
homebranch => $library_A, |
| 308 |
holdingbranch => $library_A |
| 309 |
}); |
| 310 |
|
| 311 |
# Test hold_fulfillment_policy |
| 312 |
$dbh->do("DELETE FROM circulation_rules"); |
| 313 |
Koha::CirculationRules->set_rules( |
| 314 |
{ |
| 315 |
categorycode => undef, |
| 316 |
itemtype => $itemtype, |
| 317 |
branchcode => undef, |
| 318 |
rules => { |
| 319 |
issuelength => 7, |
| 320 |
lengthunit => 8, |
| 321 |
reservesallowed => 99, |
| 322 |
holds_per_record => 99, |
| 323 |
onshelfholds => 2, |
| 324 |
} |
| 325 |
} |
| 326 |
); |
| 327 |
Koha::CirculationRules->set_rules( |
| 328 |
{ |
| 329 |
categorycode => undef, |
| 330 |
itemtype => $itemtype2, |
| 331 |
branchcode => undef, |
| 332 |
rules => { |
| 333 |
issuelength => 7, |
| 334 |
lengthunit => 8, |
| 335 |
reservesallowed => 0, |
| 336 |
holds_per_record => 0, |
| 337 |
onshelfholds => 2, |
| 338 |
} |
| 339 |
} |
| 340 |
); |
| 341 |
|
| 342 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber1, patron => $patron1 }); |
| 343 |
is( $is, 1, "Items availability: 2 items, one allowed by smart rule but not checked out, another one not allowed to be held by smart rule" ); |
| 344 |
|
| 345 |
AddIssue( $patron2->unblessed, $item1_1->barcode ); |
| 346 |
|
| 347 |
$is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber1, patron => $patron1 }); |
| 348 |
is( $is, 0, "Items availability: 2 items, one allowed by smart rule and checked out, another one not allowed to be held by smart rule" ); |
| 349 |
|
| 350 |
AddReturn( $item1_1->barcode ); |
| 351 |
|
| 352 |
|
| 288 |
# Cleanup |
353 |
# Cleanup |
| 289 |
$schema->storage->txn_rollback; |
354 |
$schema->storage->txn_rollback; |
| 290 |
|
355 |
|
| 291 |
- |
|
|