+
+ # Now we simulate the delete as done from the cron job (with dontmerge)
+ # First, restore auth1 and add 609 back in bib1
+ $auth1 = MARC::Record->new;
+ $auth1->append_fields( MARC::Field->new( '109', '', '', 'a' => 'DEL'));
+ $authid1 = AddAuthority( $auth1, undef, $authtype1 );
+ $marc1->append_fields(
+ MARC::Field->new( '609', '', '', a => 'DEL', 9 => "$authid1" ),
+ );
+ ModBiblio( $marc1, $biblionumber, '' );
+ # Instead of going through DelAuthority, we manually delete the auth
+ # record and call merge afterwards.
+ # This mimics deleting an authority and calling merge later in the
+ # merge_authority.pl cron job (when dontmerge is enabled).
+ C4::Context->dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid1 );
+ @zebrarecords = ( $marc1 );
+ $index = 0;
+ merge( $authid1, undef );
+ # Final check
+ $marc1 = C4::Biblio::GetMarcBiblio( $biblionumber );
+ is( $marc1->field('609'), undef, 'Merge removed the 609 again even after deleting the authority record' );