Bugzilla – Attachment 148414 Details for
Bug 33159
Thesaurus is not defined by second indicator for controlled fields outside of 6XX
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33159: Unit tests
Bug-33159-Unit-tests.patch (text/plain), 7.25 KB, created by
Nick Clemens (kidclamp)
on 2023-03-20 14:31:56 UTC
(
hide
)
Description:
Bug 33159: Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-03-20 14:31:56 UTC
Size:
7.25 KB
patch
obsolete
>From afd01c1479750677b6e7128fa315f4503d6536d9 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 7 Mar 2023 19:23:22 +0000 >Subject: [PATCH] Bug 33159: Unit tests > >Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org> >Signed-off-by: Frank Hansen <frank.hansen@ub.lu.se> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Heading.t | 68 ++++++++++++++++++++++++++------- > t/db_dependent/Heading_MARC21.t | 12 +++++- > 2 files changed, 64 insertions(+), 16 deletions(-) > >diff --git a/t/db_dependent/Heading.t b/t/db_dependent/Heading.t >index c839dea56e..6b47065573 100755 >--- a/t/db_dependent/Heading.t >+++ b/t/db_dependent/Heading.t >@@ -21,6 +21,7 @@ use warnings; > use Test::More tests => 4; > > use t::lib::Mocks; >+use Test::MockModule;; > > BEGIN { > use_ok('C4::Heading', qw( field valid_heading_subfield )); >@@ -63,40 +64,79 @@ subtest "UNIMARC tests" => sub { > }; > > subtest "_search tests" => sub { >- plan tests => 3; >+ >+ plan tests => 6; > > t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); > t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch'); > my $search = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search'); > >- $search->mock( >- 'search_auth_compat', >- sub { >- my $self = shift; >- my $search_query = shift; >- return $search_query; >- } >- ); >+ $search->mock('search_auth_compat', sub { >+ my $self = shift; >+ my $search_query = shift; >+ return $search_query; >+ }); > >- my ( $field, $heading, $search_query, $terms ); > >- $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,' ); >+ my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' ); >+ my $heading = C4::Heading->new_from_field($field); >+ my $search_query = $heading->_search( 'match-heading' ); >+ my $terms = $search_query->{query}->{bool}->{must}; >+ my $expected_terms = [ >+ { term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } }, >+ { term => { 'subject-heading-thesaurus.ci_raw' => 'a' } }, >+ ]; >+ is_deeply( $terms, $expected_terms, "Search formed as expected for a subject with second indicator 0"); >+ >+ $field = MARC::Field->new( '650', ' ', '3', a => 'Uncles', x => 'Fiction' ); > $heading = C4::Heading->new_from_field($field); > $search_query = $heading->_search( 'match-heading' ); > $terms = $search_query->{query}->{bool}->{must}; >- is_deeply( $terms->[0], { term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } }, "Search formed as expected for a non-subject field with single punctuation mark"); >+ $expected_terms = [ >+ { term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } }, >+ { term => { 'subject-heading-thesaurus.ci_raw' => 'd' } }, >+ ]; >+ is_deeply( $terms, $expected_terms, "Search formed as expected with second indicator 3"); > >+ $field = MARC::Field->new( '650', ' ', '7', a => 'Uncles', x => 'Fiction', 2 => 'special_sauce' ); >+ $heading = C4::Heading->new_from_field($field); >+ $search_query = $heading->_search( 'match-heading' ); >+ $terms = $search_query->{query}->{bool}->{must}; >+ $expected_terms = [ >+ { term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } }, >+ { term => { 'subject-heading-thesaurus-conventions.ci_raw' => 'special_sauce' } }, >+ { term => { 'subject-heading-thesaurus.ci_raw' => 'z' } }, >+ ]; >+ is_deeply( $terms, $expected_terms, "Search formed as expected with second indicator 7 and subfield 2"); >+ >+ $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,' ); >+ $heading = C4::Heading->new_from_field($field); >+ $search_query = $heading->_search( 'match-heading' ); >+ $terms = $search_query->{query}->{bool}->{must}; >+ $expected_terms = [ >+ { term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } }, >+ { term => { 'subject-heading-thesaurus.ci_raw' => 'a' } }, >+ ]; >+ is_deeply( $terms, $expected_terms, "Search formed as expected for a non-subject field with single punctuation mark"); > > $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,', e => '[author]' ); > $heading = C4::Heading->new_from_field($field); > $search_query = $heading->_search( 'match-heading' ); > $terms = $search_query->{query}->{bool}->{must}; >- is_deeply( $terms->[0], { term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } }, "Search formed as expected for a non-subject field with double punctuation, hyphen+comma"); >+ $expected_terms = [ >+ { term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } }, >+ { term => { 'subject-heading-thesaurus.ci_raw' => 'a' } }, >+ ]; >+ is_deeply( $terms, $expected_terms, "Search formed as expected for a non-subject field with double punctuation, hyphen+comma"); > > $field = MARC::Field->new( '100', ' ', '', a => 'Tolkien, J.R.R.,', e => '[author]' ); > $heading = C4::Heading->new_from_field($field); > $search_query = $heading->_search( 'match-heading' ); > $terms = $search_query->{query}->{bool}->{must}; >- is_deeply( $terms->[0], { term => { 'match-heading.ci_raw' => 'Tolkien, J.R.R' } }, "Search formed as expected for a non-subject field with double punctuation, period+comma "); >+ $expected_terms = [ >+ { term => { 'match-heading.ci_raw' => 'Tolkien, J.R.R' } }, >+ { term => { 'subject-heading-thesaurus.ci_raw' => 'a' } }, >+ ]; >+ is_deeply( $terms, $expected_terms, "Search formed as expected for a non-subject field with double punctuation, period+comma "); > > }; >diff --git a/t/db_dependent/Heading_MARC21.t b/t/db_dependent/Heading_MARC21.t >index 357d3126d4..32bd0a07cc 100755 >--- a/t/db_dependent/Heading_MARC21.t >+++ b/t/db_dependent/Heading_MARC21.t >@@ -6,7 +6,7 @@ > use strict; > use warnings; > >-use Test::More tests => 5; >+use Test::More tests => 10; > use C4::Context; > > BEGIN { >@@ -15,14 +15,22 @@ BEGIN { > > SKIP: { > skip "MARC21 heading tests not applicable to UNIMARC", 2 if C4::Context->preference('marcflavour') eq 'UNIMARC'; >- my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' ); >+ my $field = MARC::Field->new( '650', ' ', '2', a => 'Uncles', x => 'Fiction' ); > my $heading = C4::Heading->new_from_field($field); > is($heading->display_form(), 'Uncles--Fiction', 'Display form generation'); > is($heading->search_form(), 'Uncles generalsubdiv Fiction', 'Search form generation'); >+ is($heading->{thesaurus}, 'mesh', 'Thesaurus generation'); > > $field = MARC::Field->new( '830', ' ', '4', a => 'The dark is rising ;', v => '3' ); > $heading = C4::Heading->new_from_field($field); > is($heading->display_form(), 'The dark is rising ;', 'Display form generation'); > is($heading->search_form(), 'The dark is rising', 'Search form generation'); >+ is($heading->{thesaurus}, 'lcsh', 'Thesaurus generation'); >+ >+ $field = MARC::Field->new( '100', '1', '', a => 'Yankovic, Al', d => '1959-' ); >+ $heading = C4::Heading->new_from_field($field); >+ is($heading->display_form(), 'Yankovic, Al 1959-', 'Display form generation'); >+ is($heading->search_form(), 'Yankovic, Al 1959', 'Search form generation'); >+ is($heading->{thesaurus}, 'lcsh', 'Thesaurus generation'); > > } >-- >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 33159
:
147881
|
147882
|
147970
|
147980
|
147986
|
147987
|
147988
|
148032
|
148033
|
148034
|
148050
|
148051
|
148052
|
148227
|
148228
|
148229
| 148414 |
148415
|
148416