Bugzilla – Attachment 166644 Details for
Bug 30047
Add a field to auth_header to record main heading as text string
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30047: (follow-up) Fix failing tests
Bug-30047-follow-up-Fix-failing-tests.patch (text/plain), 7.83 KB, created by
Nick Clemens (kidclamp)
on 2024-05-13 14:18:48 UTC
(
hide
)
Description:
Bug 30047: (follow-up) Fix failing tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-05-13 14:18:48 UTC
Size:
7.83 KB
patch
obsolete
>From c935b5ddec7d0da72e39eb80aa553292cdd8ca49 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 13 May 2024 14:03:47 +0000 >Subject: [PATCH] Bug 30047: (follow-up) Fix failing tests > >This patch updates the test files to correctly create authorities and/or correctly >mock the needed data for authorities. > >the tests in t/db_dependent/Authority/Merge.t cover the case of 'Default' authorities >which don't have valid headings - so I had to add handling for blanking the heading field >when Default type is used. >--- > C4/AuthoritiesMarc.pm | 4 +++- > C4/Heading.pm | 1 + > t/db_dependent/Authority/Merge.t | 10 ++++++++- > t/db_dependent/Biblio.t | 4 ++++ > t/db_dependent/Koha/Authorities.t | 6 +++++ > t/db_dependent/Koha/Plugins/authority_hooks.t | 8 +++++-- > t/db_dependent/api/v1/authorities.t | 22 +++++++++++++++---- > 7 files changed, 47 insertions(+), 8 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index a0fb181de7c..b595230c5d3 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -687,6 +687,8 @@ sub AddAuthority { > } else { > $action = 'modify'; > $authority = Koha::Authorities->find($authid); >+ $authority->authtypecode($authtypecode); >+ # In the case we are changing type we need to set this to ensure heading field is correctly chosen > } > > # Insert/update the recordID in MARC record >@@ -701,7 +703,7 @@ sub AddAuthority { > authtypecode => $authtypecode, > marc => $record->as_usmarc, > marcxml => $record->as_xml_record($format), >- heading => $heading->display_form, >+ heading => $heading ? $heading->display_form : '', > } > ); > >diff --git a/C4/Heading.pm b/C4/Heading.pm >index 9a56bf9a010..653cd9636dc 100644 >--- a/C4/Heading.pm >+++ b/C4/Heading.pm >@@ -66,6 +66,7 @@ sub new_from_field { > my $marcflavour = C4::Context->preference('marcflavour'); > my $marc_handler = _marc_format_handler($marcflavour); > >+ return unless $field; > my $tag = $field->tag(); > return unless $marc_handler->valid_heading_tag( $tag, $frameworkcode, $auth ); > my $self = {}; >diff --git a/t/db_dependent/Authority/Merge.t b/t/db_dependent/Authority/Merge.t >index cfb5fd26feb..5632141dfd1 100755 >--- a/t/db_dependent/Authority/Merge.t >+++ b/t/db_dependent/Authority/Merge.t >@@ -33,6 +33,14 @@ t::lib::Mocks::mock_preference( 'marcflavour', $marcflavour ) if $marcflavour; > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > >+my $heading_module = Test::MockModule->new('C4::Heading::MARC21'); >+$heading_module->mock( >+ 'valid_heading_tag', >+ sub { >+ return 1; >+ } >+); >+ > # Global variables, mocking and framework modifications > our @linkedrecords; > my $mocks = set_mocks(); >@@ -183,7 +191,7 @@ subtest 'Test merge A1 to B1 (changing authtype)' => sub { > my $authid1 = AddAuthority( $auth1, undef, $authtype1 ); > my $auth2 = MARC::Record->new; > $auth2->append_fields( MARC::Field->new( '112', '0', '0', 'a' => 'Batman', c => 'cc' )); >- my $authid2 = AddAuthority($auth1, undef, $authtype2 ); >+ my $authid2 = AddAuthority($auth2, undef, $authtype2 ); > > # create a biblio with one 109 and two 609s to be touched > # seems exceptional see bug 13760 comment10 >diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t >index 42f1c861886..1a5bf99fd2e 100755 >--- a/t/db_dependent/Biblio.t >+++ b/t/db_dependent/Biblio.t >@@ -643,6 +643,10 @@ subtest 'UNIMARC' => sub { > # Mock the auth type data for UNIMARC > $dbh->do("UPDATE auth_types SET auth_tag_to_report = '106' WHERE auth_tag_to_report = '100'") or die $dbh->errstr; > >+ $dbh->do( >+ "UPDATE marc_subfield_structure SET tagfield = '106' WHERE authtypecode = 'PERSO_NAME' AND frameworkcode='' AND tagfield='100' " >+ ) or die $dbh->errstr; >+ > run_tests('UNIMARC'); > $schema->storage->txn_rollback; > $schema->storage->txn_begin; >diff --git a/t/db_dependent/Koha/Authorities.t b/t/db_dependent/Koha/Authorities.t >index 422307c7b97..b9a1e08fc44 100755 >--- a/t/db_dependent/Koha/Authorities.t >+++ b/t/db_dependent/Koha/Authorities.t >@@ -187,6 +187,12 @@ unimarc,*,ind1:auth2,ind2:auth1|); > $record = MARC::Record->new; > $record->append_fields( MARC::Field->new( '210', '1', '2', a => 'Name' ) ); > $type = $builder->build({ source => 'AuthType', value => { auth_tag_to_report => '210'} }); >+ my $dbh = C4::Context->dbh; >+ $dbh->do( >+ "INSERT INTO marc_subfield_structure (tagfield,authtypecode,frameworkcode) VALUES ('210',?,'')", undef, >+ $type->{authtypecode} >+ ) or die $dbh->errstr; >+ > $authid = C4::AuthoritiesMarc::AddAuthority( $record, undef, $type->{authtypecode} ); > $auth = Koha::Authorities->find( $authid ); > is( $auth->controlled_indicators({ biblio_tag => '345' })->{ind1}, '2', 'UNIMARC: Swapped ind2' ); >diff --git a/t/db_dependent/Koha/Plugins/authority_hooks.t b/t/db_dependent/Koha/Plugins/authority_hooks.t >index f0f15750880..be0b12c4915 100755 >--- a/t/db_dependent/Koha/Plugins/authority_hooks.t >+++ b/t/db_dependent/Koha/Plugins/authority_hooks.t >@@ -53,11 +53,15 @@ subtest 'after_authority_action hook' => sub { > my $plugin = Koha::Plugin::Test->new->enable; > my $id; > >- warnings_exist { ( $id ) = C4::AuthoritiesMarc::AddAuthority( MARC::Record->new, undef, 'PERSO_NAME' ); } >+ my $record = MARC::Record->new; >+ $record->append_fields( MARC::Field->new( '100', '1', '2', a => 'Name' ) ); >+ my $type = $builder->build( { source => 'AuthType', value => { auth_tag_to_report => '100' } } ); >+ >+ warnings_exist { ( $id ) = C4::AuthoritiesMarc::AddAuthority( $record, undef, $type->{authtypecode} ); } > qr/after_authority_action called with action: create, id: \d+/, > 'AddAuthority calls the hook with action=create, id passed'; > >- warnings_exist { C4::AuthoritiesMarc::ModAuthority( $id, MARC::Record->new, 'PERSO_NAME', { skip_merge => 1 } ); } >+ warnings_exist { C4::AuthoritiesMarc::ModAuthority( $id, $record, $type->{authtypecode}, { skip_merge => 1 } ); } > qr/after_authority_action called with action: modify, id: $id/, > 'ModAuthority calls the hook with action=modify, id passed'; > >diff --git a/t/db_dependent/api/v1/authorities.t b/t/db_dependent/api/v1/authorities.t >index d0701b14159..41c9be864e3 100755 >--- a/t/db_dependent/api/v1/authorities.t >+++ b/t/db_dependent/api/v1/authorities.t >@@ -252,16 +252,30 @@ subtest 'put() tests' => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > my $userid = $patron->userid; > >- my $authority = $builder->build_object({ 'class' => 'Koha::Authorities', value => { >- marcxml => q|<?xml version="1.0" encoding="UTF-8"?> >+ my $authority_type = $builder->build_object( >+ { >+ 'class' => 'Koha::Authority::Types', >+ value => { >+ auth_tag_to_report => '110', >+ } >+ } >+ ); >+ my $authority = $builder->build_object( >+ { >+ 'class' => 'Koha::Authorities', >+ value => { >+ marcxml => q|<?xml version="1.0" encoding="UTF-8"?> > <record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"> > <controlfield tag="001">1001</controlfield> > <datafield tag="110" ind1=" " ind2=" "> > <subfield code="9">102</subfield> > <subfield code="a">My Corporation</subfield> > </datafield> >-</record>| >- } }); >+</record>|, >+ authtypecode => $authority_type->authtypecode, >+ } >+ } >+ ); > > my $authid = $authority->id; > my $authtypecode = $authority->authtypecode; >-- >2.39.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 30047
:
161208
|
161209
|
161210
|
161211
|
161213
|
161214
|
161215
|
161216
|
166522
|
166523
|
166524
|
166525
| 166644