From 7356817685db5a2ac3b31e7be0b32f7719e3b2d9 Mon Sep 17 00:00:00 2001
From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Date: Fri, 15 Nov 2024 11:19:12 +0000
Subject: [PATCH] Bug 33641: Fix StoreLastBorrower.t

---
 t/db_dependent/Circulation/StoreLastBorrower.t | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/t/db_dependent/Circulation/StoreLastBorrower.t b/t/db_dependent/Circulation/StoreLastBorrower.t
index c3121bb954d..c4c7f37a225 100755
--- a/t/db_dependent/Circulation/StoreLastBorrower.t
+++ b/t/db_dependent/Circulation/StoreLastBorrower.t
@@ -38,10 +38,11 @@ subtest 'Test StoreLastBorrower' => sub {
 
     t::lib::Mocks::mock_preference( 'StoreLastBorrower', '1' );
 
-    my $patron = $builder->build(
+    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
+    my $patron  = $builder->build(
         {
             source => 'Borrower',
-            value  => { privacy => 1, }
+            value  => { privacy => 1, branchcode => $library->branchcode }
         }
     );
 
@@ -57,6 +58,8 @@ subtest 'Test StoreLastBorrower' => sub {
         }
     );
 
+    t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } );
+
     $item = $item->get_from_storage;
     my $patron_object = $item->last_returned_by();
     is( $patron_object, undef, 'Koha::Item::last_returned_by returned undef' );
-- 
2.39.3 (Apple Git-146)