From e0d32e073abdf4f7705f310ff0eeac52cfbc1721 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 3 Sep 2026 13:24:41 +0100 Subject: [PATCH] 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 Signed-off-by: Pedro Amorim --- t/db_dependent/Circulation.t | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index ef16239dd4..2a5b7b7f26 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -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;