From ec1bf1c9e855784da5702dbc21133156eb25b0e7 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Mon, 15 Mar 2021 16:35:53 +0000
Subject: [PATCH] Bug 24295: Replace mock in t/db_dependent/Search.t

Replace the mock of GetTransfers in this test with a mock of transfers
data

Test plan
1/ Run t/db_dependent/Search.t
2/ Confirm it passes
3/ Apply patch
4/ Repeat steps 1-2
---
 t/db_dependent/Search.t | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/t/db_dependent/Search.t b/t/db_dependent/Search.t
index 3b4e6d38dc..5f41ef71cd 100755
--- a/t/db_dependent/Search.t
+++ b/t/db_dependent/Search.t
@@ -31,6 +31,7 @@ use Test::More tests => 3;
 use Test::MockModule;
 use Test::Warn;
 use t::lib::Mocks;
+use t::lib::TestBuilder;
 
 use Koha::Caches;
 
@@ -45,6 +46,8 @@ use File::Path;
 our $child;
 our $datadir;
 
+my $builder = t::lib::TestBuilder->new;
+
 sub index_sample_records_and_launch_zebra {
     my ($datadir, $marc_type) = @_;
 
@@ -700,15 +703,17 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'
     ## Regression test for Bug 10741
 
     # make one of the test items appear to be in transit
-    my $circ_module = Test::MockModule->new('C4::Circulation');
-    $circ_module->mock('GetTransfers', sub {
-        my $itemnumber = shift // -1;
-        if ($itemnumber == 11) {
-            return ('2013-07-19', 'MPL', 'CPL');
-        } else {
-            return;
+    my $transfer = $builder->build(
+        {
+            source => 'Branchtransfer',
+            value  => {
+                itemnumber => 11,
+                frombranch => 'MPL',
+                tobranch   => 'CPL',
+                datesent   => \'NOW()'
+            }
         }
-    });
+    );
 
     ($error, $results_hashref, $facets_loop) = getRecords("TEST12121212","TEST12121212",[ ], [ 'biblioserver' ],20,0,\%branches,\%itemtypes,$query_type,0);
     @newresults = searchResults({'interface'=>'intranet'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0,
-- 
2.20.1