From fcb5c124b0d3551f3eb1faa1d42b821bc7bdc14b Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Fri, 17 Jun 2022 15:01:04 +0100
Subject: [PATCH] Bug 28854: Unit test for AddReturn addition

This patch adds tests for the AddReturn change that adds an 'InBundle' message
to the return.
---
 t/db_dependent/Circulation.t | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t
index e2a1d5dbf9..232757e532 100755
--- a/t/db_dependent/Circulation.t
+++ b/t/db_dependent/Circulation.t
@@ -4286,6 +4286,25 @@ subtest 'AddReturn | recalls' => sub {
     $recall1->set_cancelled;
 };
 
+subtest 'AddReturn | bundles' => sub {
+    plan tests => 1;
+
+    my $schema = Koha::Database->schema;
+    $schema->storage->txn_begin;
+
+    my $patron1 = $builder->build_object({ class => 'Koha::Patrons' });
+    my $host_item1 = $builder->build_sample_item;
+    my $bundle_item1 = $builder->build_sample_item;
+    $schema->resultset('ItemBundle')
+      ->create(
+        { host => $host_item1->itemnumber, item => $bundle_item1->itemnumber } );
+
+    my ( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $bundle_item1->barcode, $bundle_item1->homebranch );
+    is($messages->{InBundle}->id, $host_item1->id, 'AddReturn returns InBundle host item when item is part of a bundle');
+
+    $schema->storage->txn_rollback;
+};
+
 subtest 'AddRenewal and AddIssuingCharge tests' => sub {
 
     plan tests => 13;
-- 
2.20.1