Bug 41728: (QA follow-up) Add coverage for the Wrongbranch blocker

No test in the suite asserted on $messages->{Wrongbranch} content
despite this being one of the blockers AddReturn's rewired
availability check produces (AllowReturnToBranch enforcement, moved
into Koha::Item->can_be_returned_at / Koha::Item::Availability::Checkin
by this bug). Add coverage for it.

Test plan:
1. prove t/db_dependent/Circulation.t
=> SUCCESS: 88 tests pass.

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-09-03 13:24:41 +01:00 committed by Pedro Amorim
parent 8bcd634fb9
commit e0d32e073a
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 30 additions and 1 deletions

View File

@ -19,7 +19,7 @@ use Modern::Perl;
use utf8;
use Test::NoWarnings;
use Test::More tests => 89;
use Test::More tests => 90;
use Test::Exception;
use Test::MockModule;
use Test::Deep qw( cmp_deeply );
@ -8155,6 +8155,35 @@ subtest 'Tests for BlockReturnOfWithdrawnItems' => sub {
);
};
subtest 'Tests for Wrongbranch blocker (AllowReturnToBranch)' => sub {
plan tests => 1;
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' );
my $library_a = $builder->build_object( { class => 'Koha::Libraries' } );
my $library_b = $builder->build_object( { class => 'Koha::Libraries' } );
my $item = $builder->build_sample_item(
{ homebranch => $library_a->branchcode, holdingbranch => $library_a->branchcode } );
my @return = AddReturn( $item->barcode, $library_b->branchcode, 0, undef );
is_deeply(
\@return,
[
0,
{
NotIssued => $item->barcode,
Wrongbranch => {
Wrongbranch => $library_b->branchcode,
Rightbranch => $library_a->branchcode,
}
},
undef,
{}
],
"AddReturn reports the Wrongbranch blocker with the item's homebranch as the right branch"
);
};
subtest 'Tests for transfer not in transit' => sub {
plan tests => 2;