Bugzilla – Attachment 137631 Details for
Bug 31023
Cannot create new GENRE/FORM authorities when QueryRegexEscapeOptions set to 'Unescape escaped'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31023: Unit tests
Bug-31023-Unit-tests.patch (text/plain), 2.50 KB, created by
Nick Clemens
on 2022-07-12 13:48:27 UTC
(
hide
)
Description:
Bug 31023: Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2022-07-12 13:48:27 UTC
Size:
2.50 KB
patch
obsolete
>From 0a7858dfbaece65131ae0d7e9948e66e7e4f9d0b Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 12 Jul 2022 13:46:27 +0000 >Subject: [PATCH] Bug 31023: Unit tests > >--- > t/AuthoritiesMarc_MARC21.t | 44 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 43 insertions(+), 1 deletion(-) > >diff --git a/t/AuthoritiesMarc_MARC21.t b/t/AuthoritiesMarc_MARC21.t >index 5c5c837124..551cb3a3ff 100755 >--- a/t/AuthoritiesMarc_MARC21.t >+++ b/t/AuthoritiesMarc_MARC21.t >@@ -6,9 +6,14 @@ > use strict; > use warnings; > >-use Test::More tests => 4; >+use Test::MockModule; >+use Test::MockObject; >+use Test::More tests => 5; >+use t::lib::Mocks; > use MARC::Record; > >+use C4::AuthoritiesMarc qw( FindDuplicateAuthority ); >+ > BEGIN { > use_ok('C4::AuthoritiesMarc::MARC21', qw( default_auth_type_location fix_marc21_auth_type_location )); > } >@@ -19,3 +24,40 @@ ok($result[1] eq 'a', "testing default_auth_type_location has first value 'a'"); > > my $marc_record = MARC::Record->new(); > is(C4::AuthoritiesMarc::MARC21::fix_marc21_auth_type_location($marc_record, '', ''), undef, "testing fix_marc21_auth_type_location returns undef with empty MARC record"); >+ >+subtest "FindDuplicateAuthority tests" => sub { >+ plan tests => 2; >+ my $zebra_search_module = Test::MockModule->new( 'C4::Search' ); >+ $zebra_search_module->mock( 'SimpleSearch', sub { >+ my $query = shift; >+ return ( undef, [$query] ); >+ }); >+ $zebra_search_module->mock( 'new_record_from_zebra', sub { >+ my (undef, $query ) = @_; >+ my $marc = MARC::Record->new; >+ $marc->append_fields( >+ MARC::Field->new( '001', $query ), >+ ); >+ return $marc; >+ }); >+ my $es_search_module = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch::Search' ); >+ $es_search_module->mock( 'simple_search_compat', sub { >+ my (undef, $query) = @_; >+ return ( undef, [$query] ); >+ }); >+ >+ my $record = MARC::Record->new; >+ $record->append_fields( >+ MARC::Field->new('155', '', '', a => 'Potato' ), >+ ); >+ >+ t::lib::Mocks::mock_preference( 'SearchEngine', 'Zebra' ); >+ my ($query) = FindDuplicateAuthority( $record, "GENRE/FORM" ); >+ is( $query, q{at:"GENRE/FORM" AND he:"Potato"}, "Query formed correctly for Zebra"); >+ >+ t::lib::Mocks::mock_preference( 'SearchEngine', 'Elasticsearch' ); >+ ($query) = FindDuplicateAuthority( $record, "GENRE/FORM" ); >+ is( $query, q{at:"GENRE/FORM" AND he:"Potato"}, "Query formed correctly for Elasticsearch"); >+ >+}; >+ >-- >2.30.2
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 31023
:
137631
|
137632
|
137662
|
137663
|
139852
|
139853