Bugzilla – Attachment 184118 Details for
Bug 37883
Add a filter for staff search results to filter by library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37883: (follow-up) Add a test
Bug-37883-follow-up-Add-a-test.patch (text/plain), 4.23 KB, created by
Lucas Gass (lukeg)
on 2025-07-15 17:00:54 UTC
(
hide
)
Description:
Bug 37883: (follow-up) Add a test
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-07-15 17:00:54 UTC
Size:
4.23 KB
patch
obsolete
>From e55fb4686a0e9dbcc62dd2e88224d2357a7db51e Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Tue, 15 Jul 2025 16:59:50 +0000 >Subject: [PATCH] Bug 37883: (follow-up) Add a test > >--- > t/db_dependent/Search.t | 96 ++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 95 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Search.t b/t/db_dependent/Search.t >index beaf6cb43ab..ddb8e01c1d0 100755 >--- a/t/db_dependent/Search.t >+++ b/t/db_dependent/Search.t >@@ -27,7 +27,7 @@ require C4::Context; > use open ':std', ':encoding(utf8)'; > > use Test::NoWarnings; >-use Test::More tests => 4; >+use Test::More tests => 5; > use Test::MockModule; > use Test::Warn; > use t::lib::Mocks; >@@ -235,6 +235,100 @@ sub mock_GetMarcSubfieldStructure { > } > } > >+subtest 'searchResults branch-specific counts for Bug 37883' => sub { >+ plan tests => 8; >+ >+ use C4::Search qw( searchResults ); >+ >+ my $record = MARC::Record->new(); >+ $record->add_fields( >+ [ '001', '123' ], >+ [ '245', ' ', ' ', a => 'Test record for branch counting' ], >+ [ '999', ' ', ' ', c => '123', d => '123' ], >+ >+ # Available item from CPL >+ [ >+ '952', ' ', ' ', >+ a => 'CPL', # homebranch >+ b => 'CPL', # holdingbranch >+ p => 'TEST001', # barcode >+ y => 'BK', # itemtype >+ '9' => '1001', # itemnumber >+ '0' => '0', # withdrawn >+ '1' => '0', # itemlost >+ '4' => '0', # damaged >+ '7' => '0', # notforloan >+ q => '', # onloan >+ ], >+ >+ # Withdrawn item from CPL >+ [ >+ '952', ' ', ' ', >+ a => 'CPL', # homebranch >+ b => 'CPL', # holdingbranch >+ p => 'TEST002', # barcode >+ y => 'BK', # itemtype >+ '9' => '1002', # itemnumber >+ '0' => '1', # withdrawn = yes >+ '1' => '0', # itemlost >+ '4' => '0', # damaged >+ '7' => '0', # notforloan >+ q => '', # onloan >+ ], >+ >+ # Available item from MPL >+ [ >+ '952', ' ', ' ', >+ a => 'MPL', # homebranch >+ b => 'MPL', # holdingbranch >+ p => 'TEST003', # barcode >+ y => 'BK', # itemtype >+ '9' => '1003', # itemnumber >+ '0' => '0', # withdrawn >+ '1' => '0', # itemlost >+ '4' => '0', # damaged >+ '7' => '0', # notforloan >+ q => '', # onloan >+ ], >+ ); >+ >+ # Mock userenv for CPL branch >+ my $context_mock = Test::MockModule->new('C4::Context'); >+ $context_mock->mock( >+ 'userenv', >+ sub { >+ return { >+ branchcode => 'CPL', >+ branch => 'CPL', >+ number => 123, >+ }; >+ } >+ ); >+ >+ my @results = searchResults( >+ { interface => 'intranet' }, >+ 'test query', >+ 1, # total hits >+ 10, # results per page >+ 0, # offset >+ 0, # scan >+ [ $record->as_xml() ] >+ ); >+ >+ # Test that new branch count fields exist in search results >+ ok( defined $results[0]->{branchavailablecount}, 'branchavailablecount exists' ); >+ ok( defined $results[0]->{branchonloancount}, 'branchonloancount exists' ); >+ ok( defined $results[0]->{branchothercount}, 'branchothercount exists' ); >+ ok( defined $results[0]->{branchtotalcount}, 'branchtotalcount exists' ); >+ >+ is( $results[0]->{branchavailablecount}, 1, 'Branch available count: 1 available item at CPL' ); >+ is( $results[0]->{branchothercount}, 1, 'Branch other count: 1 withdrawn item at CPL' ); >+ is( $results[0]->{branchtotalcount}, 2, 'Branch total count: 2 items total at CPL' ); >+ >+ # Test that global counts still include all items from all branches >+ is( $results[0]->{availablecount}, 2, 'Global available count: 2 items available at all branches' ); >+}; >+ > sub run_marc21_search_tests { > > $marcflavour = 'MARC21'; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37883
:
171256
|
171257
|
171261
|
171286
|
171287
|
171289
|
171291
|
171406
|
171407
|
171408
|
171409
|
171410
|
171411
|
176697
|
177306
|
177784
|
177785
|
177786
|
177787
|
177788
|
177789
|
177790
|
177791
|
178772
|
178773
|
178774
|
178775
|
178776
|
178777
|
179688
|
179689
|
179690
|
179691
|
179692
|
179693
|
179694
|
179920
|
179921
|
179922
|
179923
|
179924
|
179925
|
179926
|
179927
|
184008
|
184009
|
184010
|
184011
|
184012
|
184013
|
184014
|
184015
|
184117
| 184118