@@ -, +, @@ --> Tests fail --> Note verbose output for Tests for GetOtherReserves: ok 3 - GetOtherReserves should not set found status not ok 4 - GetOtherReserves should not set itemnumber on biblio-level hold --> The itemnumber is set on a biblio-level hold, but the found status is not set! --> Tests pass --- t/db_dependent/Circulation.t | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) --- a/t/db_dependent/Circulation.t +++ a/t/db_dependent/Circulation.t @@ -6133,6 +6133,74 @@ subtest 'Tests for RecordLocalUseOnReturn' => sub { [ 0, { NotIssued => $item->barcode, withdrawn => 1, LocalUse => 1 }, undef, {} ], "Local use is recorded"); }; +subtest 'Tests for GetOtherReserves' => sub { + plan tests => 4; + + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $patron_1 = $builder->build_object( + { + class => 'Koha::Patrons', + } + ); + my $patron_2 = $builder->build_object( + { + class => 'Koha::Patrons', + } + ); + + # GetOtherReserves uses the ItemType object to check not-for-loan value + my $itype = $builder->build_object( + { + class => 'Koha::ItemTypes', + value => { + notforloan => 0, + } + } + ); + + my $item = $builder->build_object( + { + class => 'Koha::Items', + value => { + itype => $itype->itemtype, + homebranch => $library->branchcode, + } + } + ); + + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); + + my $reserve_1_id = AddReserve( + { + branchcode => $item->homebranch, + borrowernumber => $patron_1->borrowernumber, + biblionumber => $item->biblionumber, + } + ); + + my $reserve_2_id = AddReserve( + { + branchcode => $item->homebranch, + borrowernumber => $patron_2->borrowernumber, + biblionumber => $item->biblionumber, + } + ); + + my $messages; + my $nextreservinfo; + ( $messages, $nextreservinfo ) = GetOtherReserves( $item->itemnumber ); + + my $reserve_1 = Koha::Holds->search( { reserve_id => $reserve_1_id } )->next; + + is( + $nextreservinfo->{reserve_id}, $reserve_1->reserve_id, + 'GetOtherReserves should return the next reserve in line' + ); + is( $reserve_1->priority, 1, 'Next reserve in line should be priority 1' ); + ok( !$reserve_1->found, 'GetOtherReserves should not set found status' ); + ok( !$reserve_1->itemnumber, 'GetOtherReserves should not set itemnumber on a biblio-level hold' ); +}; + $schema->storage->txn_rollback; C4::Context->clear_syspref_cache(); $branches = Koha::Libraries->search(); --