Bugzilla – Attachment 156551 Details for
Bug 28166
Optionally add MARC fields to authority search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28166: (QA follow-up) Fix and tidy tests and code
Bug-28166-QA-follow-up-Fix-and-tidy-tests-and-code.patch (text/plain), 5.40 KB, created by
Jonathan Druart
on 2023-10-04 14:53:23 UTC
(
hide
)
Description:
Bug 28166: (QA follow-up) Fix and tidy tests and code
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-10-04 14:53:23 UTC
Size:
5.40 KB
patch
obsolete
>From 3bb83e89e118e77180a0ad872a0bad7c72910811 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 25 Sep 2023 13:50:30 +0000 >Subject: [PATCH] Bug 28166: (QA follow-up) Fix and tidy tests and code > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/Breeding.pm | 3 +- > .../data/mysql/atomicupdate/bug_28166.pl | 14 ++++--- > t/db_dependent/Breeding.t | 38 +++++++++++-------- > 3 files changed, 34 insertions(+), 21 deletions(-) > >diff --git a/C4/Breeding.pm b/C4/Breeding.pm >index b441e4d6fb7..8dbaae9fff3 100644 >--- a/C4/Breeding.pm >+++ b/C4/Breeding.pm >@@ -315,7 +315,7 @@ sub _handle_one_result { > $row->{breedingid} = $breedingid; > $row->{isbn}=_isbn_replace($row->{isbn}); > my $pref_newtags = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch'); >- $row = _add_custom_field_rowdata($row, $marcrecord, $pref_newtags); >+ $row = _add_custom_field_rowdata( $row, $marcrecord, $pref_newtags ); > } > return ( $row, $error ); > } >@@ -347,6 +347,7 @@ sub _do_xslt_proc { > sub _add_custom_field_rowdata > { > my ( $row, $record, $pref_newtags ) = @_; >+ $pref_newtags //= ''; > my $pref_flavour = C4::Context->preference('MarcFlavour'); > > $pref_newtags =~ s/^\s+|\s+$//g; >diff --git a/installer/data/mysql/atomicupdate/bug_28166.pl b/installer/data/mysql/atomicupdate/bug_28166.pl >index 1939efcd5f7..ea99ac1d543 100755 >--- a/installer/data/mysql/atomicupdate/bug_28166.pl >+++ b/installer/data/mysql/atomicupdate/bug_28166.pl >@@ -1,15 +1,19 @@ > use Modern::Perl; > > return { >- bug_number => "28166", >+ bug_number => "28166", > description => "Add system preference for additional columns for Z39.50 authority search results", >- up => sub { >+ up => sub { > my ($args) = @_; >- my ($dbh, $out) = @$args{qw(dbh out)}; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ > # Do you stuffs here >- $dbh->do(q{INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+ $dbh->do( >+ q{INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES > ('AdditionalFieldsInZ3950ResultAuthSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of an authority Z39.50 search', 'Free') >-}); >+} >+ ); >+ > # Print useful stuff here > # sysprefs > say $out "Added new system preference 'AdditionalFieldsInZ3950ResultAuthSearch'"; >diff --git a/t/db_dependent/Breeding.t b/t/db_dependent/Breeding.t >index dd0af9b7282..c88763076bd 100755 >--- a/t/db_dependent/Breeding.t >+++ b/t/db_dependent/Breeding.t >@@ -56,7 +56,7 @@ subtest '_do_xslt_proc' => sub { > }; > #Group 4: testing _add_custom_field_rowdata (part of Z3950Search) > subtest '_add_custom_field_rowdata' => sub { >- plan tests => 3; >+ plan tests => 5; > test_add_custom_field_rowdata(); > }; > >@@ -237,28 +237,36 @@ sub test_do_xslt { > > sub test_add_custom_field_rowdata { > my $row = { >- biblionumber => 0, >- server => "testServer", >- breedingid => 0, >- title => "Just a title" >- }; >+ biblionumber => 0, >+ server => "testServer", >+ breedingid => 0, >+ title => "Just a title" >+ }; > > my $biblio = MARC::Record->new(); > $biblio->append_fields( >- MARC::Field->new('245', ' ', ' ', a => 'Just a title'), >- MARC::Field->new('035', ' ', ' ', a => 'First 035'), >- MARC::Field->new('035', ' ', ' ', a => 'Second 035') >+ MARC::Field->new( '245', ' ', ' ', a => 'Just a title' ), >+ MARC::Field->new( '035', ' ', ' ', a => 'First 035' ), >+ MARC::Field->new( '035', ' ', ' ', a => 'Second 035' ) > ); > >- t::lib::Mocks::mock_preference('AdditionalFieldsInZ3950ResultSearch',"245\$a, 035\$a"); >+ my $pref_newtags = "245\$a, 035\$a"; > >- my $returned_row = C4::Breeding::_add_custom_field_rowdata($row, $biblio); >+ my $returned_row = C4::Breeding::_add_custom_field_rowdata( $row, $biblio, $pref_newtags ); >+ >+ is( $returned_row->{title}, "Just a title", "_add_rowdata returns the title of a biblio" ); >+ is( >+ $returned_row->{addnumberfields}[0], "245\$a", >+ "_add_rowdata returns the field number chosen in the AdditionalFieldsInZ3950ResultSearch preference" >+ ); > >- is($returned_row->{title}, "Just a title", "_add_rowdata returns the title of a biblio"); >- is($returned_row->{addnumberfields}[0], "245\$a", "_add_rowdata returns the field number chosen in the AdditionalFieldsInZ3950ResultSearch preference"); >+ # Test repeatble tags,the trailing whitespace is a normal side-effect of _add_custom_field_row_data >+ is_deeply( \$returned_row->{"035\$a"}, \[ "First 035 ", "Second 035 " ], "_add_rowdata supports repeatable tags" ); > >- # Test repeatble tags,the trailing whitespace is a normal side-effect of _add_custom_field_row_data >- is_deeply(\$returned_row->{"035\$a"}, \["First 035 ", "Second 035 "],"_add_rowdata supports repeatable tags"); >+ warning_is { C4::Breeding::_add_custom_field_rowdata( $row, $biblio, undef ) } undef, >+ 'no warn from add_custom_field_rowdata when pref_newtags undef'; >+ warning_is { C4::Breeding::_add_custom_field_rowdata( $row, $biblio, "" ) } undef, >+ 'no warn from add_custom_field_rowdata when pref_newtags blank'; > } > > sub xsl_file { >-- >2.34.1
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 28166
:
120139
|
120154
|
120155
|
148749
|
148755
|
148778
|
150590
|
150594
|
150595
|
150596
|
150601
|
153431
|
156166
|
156167
|
156550
|
156551
|
157646
|
157647