Bugzilla – Attachment 179980 Details for
Bug 34739
Linked biblios should not be merged (updated) when changes to an authority don't change the authorized heading
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34739: Unit tests
Bug-34739-Unit-tests.patch (text/plain), 5.14 KB, created by
Janusz Kaczmarek
on 2025-03-31 11:45:42 UTC
(
hide
)
Description:
Bug 34739: Unit tests
Filename:
MIME Type:
Creator:
Janusz Kaczmarek
Created:
2025-03-31 11:45:42 UTC
Size:
5.14 KB
patch
obsolete
>From e471ff4d2b0839f737819ea19032766532dbf1d8 Mon Sep 17 00:00:00 2001 >From: Janusz Kaczmarek <januszop@gmail.com> >Date: Wed, 18 Dec 2024 14:19:55 +0000 >Subject: [PATCH] Bug 34739: Unit tests > >BTW, there is a tiny adjustment to one of the previous subtests to >fit to the modified merge behaviour. > >Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> >--- > t/db_dependent/Authority/Merge.t | 93 +++++++++++++++++++++++++++++++- > 1 file changed, 91 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Authority/Merge.t b/t/db_dependent/Authority/Merge.t >index e7f50694ce..15ede67477 100755 >--- a/t/db_dependent/Authority/Merge.t >+++ b/t/db_dependent/Authority/Merge.t >@@ -5,7 +5,7 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 13; >+use Test::More tests => 14; > > use Getopt::Long; > use MARC::Record; >@@ -162,7 +162,7 @@ subtest 'Test merge A1 to modified A1, test strict mode' => sub { > ) > ); > my $MARC2 = MARC::Record->new; >- $MARC2->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Batman', '9' => $authid1 ) ); >+ $MARC2->append_fields( MARC::Field->new( '109', '', '', 'a' => 'BATMAN', '9' => $authid1 ) ); > $MARC2->append_fields( MARC::Field->new( '245', '', '', 'a' => 'All the way to heaven' ) ); > my ($biblionumber1) = AddBiblio( $MARC1, '' ); > my ($biblionumber2) = AddBiblio( $MARC2, '' ); >@@ -677,6 +677,95 @@ subtest "Test bibs not auto linked when merging" => sub { > > }; > >+subtest 'ModBiblio calls from merge' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); >+ t::lib::Mocks::mock_preference( 'AuthorityControlledIndicators', '' ); >+ t::lib::Mocks::mock_preference( 'IncludeSeeFromInSearches', '1' ); >+ >+ my $auth_record = MARC::Record->new(); >+ $auth_record->insert_fields_ordered( MARC::Field->new( '109', '1', ' ', a => 'Brown,', 'c' => 'Father' ) ); >+ my $authid = AddAuthority( $auth_record, undef, $authtype1, { skip_record_index => 1 } ); >+ >+ my $auth_record_modified = $auth_record->clone; >+ $auth_record_modified->field('109')->update( c => 'Father (Fictitious character)' ); >+ >+ my $biblio_record = MARC::Record->new(); >+ $biblio_record->insert_fields_ordered( >+ MARC::Field->new( '609', '1', '1', a => 'Brown,', 'c' => 'Father', 9 => $authid ) ); >+ my $biblionumber = AddBiblio( $biblio_record, '', { skip_record_index => 1 } ); >+ >+ my $biblio_module = Test::MockModule->new('C4::AuthoritiesMarc'); >+ $biblio_module->mock( >+ 'ModBiblio', >+ sub { warn 'ModBiblio called'; } >+ ); >+ >+ warnings_are { >+ merge( >+ { >+ mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid, MARCto => $auth_record_modified, >+ biblionumbers => [$biblionumber], >+ } >+ ); >+ } >+ ["ModBiblio called"], "real modification of bibliographic record, ModBiblio called"; >+ >+ t::lib::Mocks::mock_preference( 'SearchEngine', 'Elasticsearch' ); >+ my $mock_index = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Indexer'); >+ $mock_index->mock( 'index_records', sub { warn 'index_records called'; } ); >+ >+ warnings_are { >+ merge( >+ { >+ mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid, MARCto => $auth_record, >+ biblionumbers => [$biblionumber], >+ } >+ ); >+ } >+ ["index_records called"], "no real modification of bibliographic record, index_records called"; >+ >+ t::lib::Mocks::mock_preference( 'IncludeSeeFromInSearches', '0' ); >+ t::lib::Mocks::mock_preference( 'IncludeSeeAlsoFromInSearches', '0' ); >+ warnings_are { >+ merge( >+ { >+ mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid, MARCto => $auth_record, >+ biblionumbers => [$biblionumber], >+ } >+ ); >+ } >+ [], "no real modification of bibliographic record, index_records not called"; >+ >+ my $auth_record2 = MARC::Record->new(); >+ $auth_record2->insert_fields_ordered( MARC::Field->new( '109', '1', ' ', a => 'Chesterton, G.K.' ) ); >+ my $authid2 = AddAuthority( $auth_record2, undef, $authtype1, { skip_record_index => 1 } ); >+ >+ my $biblio_record2 = MARC::Record->new(); >+ $biblio_record2->insert_fields_ordered( >+ MARC::Field->new( '109', '1', ' ', a => 'Chesterton, G.K.', 9 => $authid2 ) ); >+ my $biblionumber2 = AddBiblio( $biblio_record2, '', { skip_record_index => 1 } ); >+ >+ my $num_biblio_edited; >+ warnings_are { >+ $num_biblio_edited = merge( >+ { >+ mergefrom => $authid, MARCfrom => $auth_record, mergeto => $authid2, MARCto => $auth_record2, >+ biblionumbers => [ $biblionumber, $biblionumber2 ], >+ } >+ ); >+ } >+ ["ModBiblio called"], "real modification of bibliographic record, ModBiblio called"; >+ is( $num_biblio_edited, 1, 'only one bibliographic record updated while merging two authorities' ); >+ >+ $schema->storage->txn_rollback; >+ >+}; >+ > sub set_mocks { > > # After we removed the Zebra code from merge, we only need to mock >-- >2.39.5
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 34739
:
175665
|
175666
|
175667
|
175668
|
179979
|
179980
|
180083
|
180187
|
180188