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 $reserve_id_2 = C4::Reserves::AddReserve( |
443 |
{ |
444 |
borrowernumber => $patron_2->borrowernumber, |
445 |
biblionumber => $biblio->biblionumber, |
446 |
priority => 2, |
447 |
itemnumber => $item_1->itemnumber, |
448 |
} |
449 |
); |
450 |
|
451 |
my $waiting_reserve_id = C4::Reserves::AddReserve( |
452 |
{ |
453 |
borrowernumber => $patron_2->borrowernumber, |
454 |
biblionumber => $biblio->biblionumber, |
455 |
priority => 0, |
456 |
found => 'W', |
457 |
itemnumber => $item_1->itemnumber, |
458 |
} |
459 |
); |
460 |
|
461 |
# item 3 is on loan |
462 |
AddIssue( $patron_3->unblessed, $item_3->barcode ); |
463 |
|
464 |
# item 4 is in transfer |
465 |
my $from = $builder->build_object( { class => 'Koha::Libraries' } ); |
466 |
my $to = $builder->build_object( { class => 'Koha::Libraries' } ); |
467 |
Koha::Item::Transfer->new( |
468 |
{ |
469 |
itemnumber => $item_4->itemnumber, |
470 |
datearrived => undef, |
471 |
frombranch => $from->branchcode, |
472 |
tobranch => $to->branchcode |
473 |
} |
474 |
)->store; |
475 |
|
476 |
my $holds = Koha::Holds->search( |
477 |
{ |
478 |
reserve_id => [ $reserve_id_1, $reserve_id_2, $waiting_reserve_id, ] |
479 |
} |
480 |
); |
481 |
|
482 |
my @items = $holds->get_items_that_can_fill; |
483 |
is_deeply( [ map { $_->itemnumber } @items ], |
484 |
[ $item_2->itemnumber, $item_5->itemnumber ], 'Only item 1 and 5 are available for filling the hold' ); |
485 |
}; |
486 |
|
411 |
$schema->storage->txn_rollback; |
487 |
$schema->storage->txn_rollback; |
412 |
|
488 |
|
413 |
1; |
489 |
1; |
414 |
- |
|
|