From 9c6f2c6c88348836fcdec6793c7fcc19f0308bb9 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 31 Mar 2023 10:44:45 +0000 Subject: [PATCH] Bug 32648: Avoid skipping record or hiding item It seems that depending on other tests, the item could be hidden from the record, or the entire record hidden because of the way we count hidden items. I add a mock for the two HIddenItems prefs and hardcode an xml record to avoid problematic data from test builder --- t/Search.t | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/t/Search.t b/t/Search.t index 9eaf5baa1f..a6fed41af3 100755 --- a/t/Search.t +++ b/t/Search.t @@ -189,18 +189,59 @@ subtest "searchResults PassItemMarcToXSLT test" => sub { my $builder = t::lib::TestBuilder->new; - my $item = $builder->build_sample_item(); - my $record = $item->biblio->metadata->record({ embed_items => 1 }); - + my $xml_record = q{ + + + 00144 a2200073 4500 + + Some boring read + + + Some boring author + + + gOlAIZMF + + + 0 + 0 + 0 + 0 + 1117 + D6C8Pj + D6C8Pj + 2023-03-31 + 0 + g57ad1Zn3NOYZ + 2023-03-31 + 2023-03-31 + gOlAIZMF + + + 553 + 553 + + +}; t::lib::Mocks::mock_preference('PassItemMarcToXSLT','1'); - warnings_like { C4::Search::searchResults({ interface => "opac" },"test",1,1,0,0,[ $record->as_xml_record ] ,undef) } + # The routine uses a count of items in DB to determine if record should be hidden. + # Our item is not in the DB, so we avoid hiding the record which would + # mean we don't call XSLTParse4Display. + # Also ensure item is not hidden + t::lib::Mocks::mock_preference('OpacHiddenItems',''); + t::lib::Mocks::mock_preference('OpacHiddenItemsHidesRecord','0'); + + warnings_like { C4::Search::searchResults({ interface => "opac" },"test",1,1,0,0,[ $xml_record ] ,undef) } [qr/Item here/], "Item field returned from default XSLT if pref set"; t::lib::Mocks::mock_preference('PassItemMarcToXSLT','0'); - warnings_like { C4::Search::searchResults({ interface => "opac" },"test",1,1,0,0,[ $record->as_xml_record ] ,undef) } + warnings_like { C4::Search::searchResults({ interface => "opac" },"test",1,1,0,0,[ $xml_record ] ,undef) } [qr/No item/], "Item field returned from default XSLT if pref set"; -- 2.30.2