Lines 19-27
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 5; |
22 |
use Test::More tests => 6; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
|
|
25 |
use C4::Circulation; |
25 |
use C4::Reserves; |
26 |
use C4::Reserves; |
26 |
use Koha::AuthorisedValueCategory; |
27 |
use Koha::AuthorisedValueCategory; |
27 |
use Koha::Database; |
28 |
use Koha::Database; |
Lines 408-413
subtest 'Desks' => sub {
Link Here
|
408 |
|
409 |
|
409 |
}; |
410 |
}; |
410 |
|
411 |
|
|
|
412 |
subtest 'get_items_that_can_fill' => sub { |
413 |
plan tests => 1; |
414 |
|
415 |
my $biblio = $builder->build_sample_biblio; |
416 |
my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
417 |
my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
418 |
my $item_3 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ) |
419 |
; # onloan |
420 |
my $item_4 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ) |
421 |
; # in transfer |
422 |
my $item_5 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
423 |
my $lost = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itemlost => 1 } ); |
424 |
my $withdrawn = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, withdrawn => 1 } ); |
425 |
my $notforloan = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } ); |
426 |
|
427 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
428 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } ); |
429 |
my $patron_3 = $builder->build_object( { class => 'Koha::Patrons' } ); |
430 |
|
431 |
t::lib::Mocks::mock_userenv( { patron => $patron_1 } ); |
432 |
|
433 |
my $reserve_id_1 = C4::Reserves::AddReserve( |
434 |
{ |
435 |
borrowernumber => $patron_1->borrowernumber, |
436 |
biblionumber => $biblio->biblionumber, |
437 |
priority => 1, |
438 |
itemnumber => $item_1->itemnumber, |
439 |
} |
440 |
); |
441 |
|
442 |
my $waiting_reserve_id = C4::Reserves::AddReserve( |
443 |
{ |
444 |
borrowernumber => $patron_2->borrowernumber, |
445 |
biblionumber => $biblio->biblionumber, |
446 |
priority => 0, |
447 |
found => 'W', |
448 |
itemnumber => $item_1->itemnumber, |
449 |
} |
450 |
); |
451 |
|
452 |
# item 3 is on loan |
453 |
AddIssue( $patron_3->unblessed, $item_3->barcode ); |
454 |
|
455 |
# item 4 is in transfer |
456 |
my $from = $builder->build_object( { class => 'Koha::Libraries' } ); |
457 |
my $to = $builder->build_object( { class => 'Koha::Libraries' } ); |
458 |
Koha::Item::Transfer->new( |
459 |
{ |
460 |
itemnumber => $item_4->itemnumber, |
461 |
datearrived => undef, |
462 |
frombranch => $from->branchcode, |
463 |
tobranch => $to->branchcode |
464 |
} |
465 |
)->store; |
466 |
|
467 |
my $holds = Koha::Holds->search( |
468 |
{ |
469 |
reserve_id => [ $reserve_id_1, $reserve_id_2, $waiting_reserve_id, ] |
470 |
} |
471 |
); |
472 |
|
473 |
my @items = $holds->get_items_that_can_fill; |
474 |
is_deeply( [ map { $_->itemnumber } @items ], |
475 |
[ $item_2->itemnumber, $item_5->itemnumber ], 'Only item 1 and 5 are available for filling the hold' ); |
476 |
}; |
477 |
|
411 |
$schema->storage->txn_rollback; |
478 |
$schema->storage->txn_rollback; |
412 |
|
479 |
|
413 |
1; |
480 |
1; |
414 |
- |
|
|