From f670e076364e336dd09340febd2f26cc7dd683d7 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 31 Jan 2017 11:46:21 +0100 Subject: [PATCH] Bug 14026: First expose the problem in Merge.t Content-Type: text/plain; charset=utf-8 Adding a test where we delete an authority and prove that the linked biblio still contains a reference to it. Test plan: [1] Run t/db_dependent/Authorities/Merge.t Signed-off-by: Marcel de Rooy --- t/db_dependent/Authorities/Merge.t | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Authorities/Merge.t b/t/db_dependent/Authorities/Merge.t index 726bad6..4005e97 100755 --- a/t/db_dependent/Authorities/Merge.t +++ b/t/db_dependent/Authorities/Merge.t @@ -4,7 +4,7 @@ use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use Getopt::Long; use MARC::Record; @@ -216,6 +216,27 @@ subtest 'Test merge A1 to B1 (changing authtype)' => sub { 'Check 612x' ); }; +subtest 'Merging authorities should handle deletes (BZ 14026)' => sub { + plan tests => 1; + + # Add authority and linked biblio, delete authority + my $auth1 = MARC::Record->new; + $auth1->append_fields( MARC::Field->new( '109', '', '', 'a' => 'DEL')); + my $authid1 = AddAuthority( $auth1, undef, $authtype1 ); + my $bib1 = MARC::Record->new; + $bib1->append_fields( + MARC::Field->new( '245', '', '', a => 'test DEL' ), + MARC::Field->new( '609', '', '', a => 'DEL', 9 => "$authid1" ), + ); + my ( $biblionumber ) = C4::Biblio::AddBiblio( $bib1, '' ); + DelAuthority( $authid1 ); + + # See what happened + my $marc1 = C4::Biblio::GetMarcBiblio( $biblionumber ); + is( $marc1->field('609') && $marc1->field('609')->subfield('9'), + $authid1, 'FIXME: Merge should be called to remove this subfield' ); +}; + sub set_mocks { # Mock ZOOM objects: They do nothing actually # Get new_record_from_zebra to return the records -- 2.1.4