Lines 4-10
Link Here
|
4 |
|
4 |
|
5 |
use Modern::Perl; |
5 |
use Modern::Perl; |
6 |
|
6 |
|
7 |
use Test::More tests => 6; |
7 |
use Test::More tests => 7; |
8 |
|
8 |
|
9 |
use Getopt::Long; |
9 |
use Getopt::Long; |
10 |
use MARC::Record; |
10 |
use MARC::Record; |
Lines 286-291
subtest 'Merging authorities should handle deletes (BZ 18070)' => sub {
Link Here
|
286 |
is( $marc1->field('609'), undef, 'Merge removed the 609 again even after deleting the authority record' ); |
286 |
is( $marc1->field('609'), undef, 'Merge removed the 609 again even after deleting the authority record' ); |
287 |
}; |
287 |
}; |
288 |
|
288 |
|
|
|
289 |
subtest "Test some specific postponed merge issues" => sub { |
290 |
plan tests => 3; |
291 |
|
292 |
my $authmarc = MARC::Record->new; |
293 |
$authmarc->append_fields( MARC::Field->new( '109', '', '', 'a' => 'aa', b => 'bb' )); |
294 |
my $id = AddAuthority( $authmarc, undef, $authtype1 ); |
295 |
my $biblio = MARC::Record->new; |
296 |
$biblio->append_fields( |
297 |
MARC::Field->new( '109', '', '', a => 'a1', 9 => $id ), |
298 |
MARC::Field->new( '612', '', '', a => 'a2', 9 => $id+1 ), |
299 |
MARC::Field->new( '612', '', '', a => 'a3', 9 => $id+2 ), |
300 |
); |
301 |
my ( $biblionumber ) = C4::Biblio::AddBiblio( $biblio, '' ); |
302 |
|
303 |
# Merge A to B postponed, A is deleted (simulated by id+1) |
304 |
# This proves the !authtypefrom condition in sub merge |
305 |
merge({ mergefrom => $id + 1, mergeto => $id, MARCto => $authmarc, biblionumbers => [ $biblionumber ] }); |
306 |
$biblio = C4::Biblio::GetMarcBiblio( $biblionumber ); |
307 |
is( $biblio->subfield('609', '9'), $id, '612 moved to 609' ); |
308 |
|
309 |
# Merge A to B postponed, delete B immediately (hits B < hits A) |
310 |
# This proves the !@record_to test in sub merge |
311 |
merge({ mergefrom => $id + 2, mergeto => $id + 1, MARCto => undef, biblionumbers => [ $biblionumber ] }); |
312 |
$biblio = C4::Biblio::GetMarcBiblio( $biblionumber ); |
313 |
is( $biblio->field('612'), undef, 'Last 612 must be gone' ); |
314 |
|
315 |
# Show that we 'need' skip_merge; this example is far-fetched. |
316 |
# We *prove* by contradiction. |
317 |
# Suppose: Merge A to B postponed, and delete A would merge rightaway. |
318 |
# (You would need some special race condition with merge.pl to do so.) |
319 |
# The modify merge would be useless after that. |
320 |
@linkedrecords = ( $biblionumber ); |
321 |
my $restored_mocks = set_mocks(); |
322 |
DelAuthority({ authid => $id }); # delete A |
323 |
$restored_mocks->{auth_mod}->unmock_all; |
324 |
$biblio = C4::Biblio::GetMarcBiblio( $biblionumber ); |
325 |
is( $biblio->subfield('109', '9'), $id, 'If the 109 is no longer present, another modify merge would not bring it back' ); |
326 |
}; |
327 |
|
289 |
sub set_mocks { |
328 |
sub set_mocks { |
290 |
# After we removed the Zebra code from merge, we only need to mock |
329 |
# After we removed the Zebra code from merge, we only need to mock |
291 |
# get_usage_count and linked_biblionumbers here. |
330 |
# get_usage_count and linked_biblionumbers here. |
292 |
- |
|
|