From 284ff2d52c1afb481cd918221f5bdd2de9f861e9 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 26 Jan 2024 13:15:12 +0000 Subject: [PATCH] Bug 29522: Unit test Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer (cherry picked from commit 3954808ac5052a53d5fa40502a4f7bd991be80ab) Signed-off-by: Fridolin Somers --- t/db_dependent/Authority/Merge.t | 40 +++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Authority/Merge.t b/t/db_dependent/Authority/Merge.t index 0720ab329b..0fd332ab4d 100755 --- a/t/db_dependent/Authority/Merge.t +++ b/t/db_dependent/Authority/Merge.t @@ -4,11 +4,12 @@ use Modern::Perl; -use Test::More tests => 11; +use Test::More tests => 12; use Getopt::Long; use MARC::Record; use Test::MockModule; +use Test::Warn; use t::lib::Mocks; use t::lib::TestBuilder; @@ -516,6 +517,43 @@ subtest 'Test how merge handles controlled indicators' => sub { is( $biblio2->subfield('609', '2'), undef, 'No subfield $2 left' ); }; +subtest "Test bibs not auto linked when merging" => sub { + plan tests => 1; + + my $authmarc = MARC::Record->new; + $authmarc->append_fields( MARC::Field->new( '109', '', '', 'a' => 'aa', b => 'bb' ) ); + my $oldauthmarc = MARC::Record->new; + $oldauthmarc->append_fields( MARC::Field->new( '112', '', '', c => 'cc' ) ); + my $new_id = AddAuthority( $authmarc, undef, $authtype1 ); + my $old_id = AddAuthority( $oldauthmarc, undef, $authtype1 ); + my $biblio = MARC::Record->new; + $biblio->append_fields( + MARC::Field->new( '109', '', '', a => 'a1', 9 => $old_id ), + MARC::Field->new( '612', '', '', a => 'a2', c => 'cc', 9 => $old_id ), + ); + my ($biblionumber) = C4::Biblio::AddBiblio( $biblio, '' ); + + my $biblio_module = Test::MockModule->new('C4::AuthoritiesMarc'); + $biblio_module->mock( + 'ModBiblio', + sub { + my ( undef, undef, undef, $params ) = @_; + warn "Auto link disabled" if $params->{disable_autolink}; + } + ); + + warnings_are { + merge( + { + mergefrom => $old_id, MARCfrom => $oldauthmarc, mergeto => $new_id, MARCto => $authmarc, + biblionumbers => [$biblionumber] + } + ); + } + ["Auto link disabled"], "Auto link disabled when merging authorities"; + +}; + sub set_mocks { # After we removed the Zebra code from merge, we only need to mock # get_usage_count and linked_biblionumbers here. -- 2.20.1