Lines 348-353
sub run_tests {
Link Here
|
348 |
like( $marcurl->[0]->{MARCURL}, qr/^https/, 'GetMarcUrls did not stumble over a preceding space' ); |
348 |
like( $marcurl->[0]->{MARCURL}, qr/^https/, 'GetMarcUrls did not stumble over a preceding space' ); |
349 |
ok( $marcflavour ne 'MARC21' || $marcurl->[1]->{MARCURL} =~ /^http:\/\//, |
349 |
ok( $marcflavour ne 'MARC21' || $marcurl->[1]->{MARCURL} =~ /^http:\/\//, |
350 |
'GetMarcUrls prefixed a MARC21 URL with http://' ); |
350 |
'GetMarcUrls prefixed a MARC21 URL with http://' ); |
|
|
351 |
|
352 |
# Automatic authority creation |
353 |
t::lib::Mocks::mock_preference('BiblioAddsAuthorities', 1); |
354 |
t::lib::Mocks::mock_preference('AutoCreateAuthorities', 1); |
355 |
my $authorities_mod = Test::MockModule->new( 'C4::AuthoritiesMarc' ); |
356 |
$authorities_mod->mock( |
357 |
'SearchAuthorities', |
358 |
sub { |
359 |
my @results; |
360 |
return \@results, 0; |
361 |
} |
362 |
); |
363 |
$success = 0; |
364 |
$field = create_author_field('Author Name'); |
365 |
eval { |
366 |
$marc_record->append_fields($field); |
367 |
$success = ModBiblio($marc_record,$biblionumber,''); |
368 |
} or do { |
369 |
diag($@); |
370 |
$success = 0; |
371 |
}; |
372 |
ok($success, "ModBiblio handles authority addition for author"); |
373 |
|
374 |
my ($author_field, $author_subfield, $author_relator_subfield) = get_author_field(); |
375 |
$field = $marc_record->field($author_field); |
376 |
ok($field->subfield($author_subfield), "ModBiblio keeps $author_field$author_subfield intact"); |
377 |
|
378 |
my $authid = $field->subfield('9'); |
379 |
ok($authid, 'ModBiblio adds authority id'); |
380 |
|
381 |
use_ok('C4::AuthoritiesMarc'); |
382 |
my $auth_record = C4::AuthoritiesMarc::GetAuthority($authid); |
383 |
ok($auth_record, 'Authority record successfully retrieved'); |
384 |
|
385 |
|
386 |
my ($auth_author_field, $auth_author_subfield) = get_auth_author_field(); |
387 |
$field = $auth_record->field($auth_author_field); |
388 |
ok($field, "Authority record contains field $auth_author_field"); |
389 |
is( |
390 |
$field->subfield($auth_author_subfield), |
391 |
'Author Name', |
392 |
'Authority $auth_author_field$auth_author_subfield contains author name' |
393 |
); |
394 |
is($field->subfield($author_relator_subfield), undef, 'Authority does not contain relator subfield'); |
395 |
|
396 |
# Reset settings |
397 |
t::lib::Mocks::mock_preference('BiblioAddsAuthorities', 0); |
398 |
t::lib::Mocks::mock_preference('AutoCreateAuthorities', 0); |
351 |
} |
399 |
} |
352 |
|
400 |
|
353 |
sub get_title_field { |
401 |
sub get_title_field { |
Lines 370-375
sub get_itemnumber_field {
Link Here
|
370 |
return ( $marc_flavour eq 'UNIMARC' ) ? ( '995', '9' ) : ( '952', '9' ); |
418 |
return ( $marc_flavour eq 'UNIMARC' ) ? ( '995', '9' ) : ( '952', '9' ); |
371 |
} |
419 |
} |
372 |
|
420 |
|
|
|
421 |
sub get_author_field { |
422 |
my $marc_flavour = C4::Context->preference('marcflavour'); |
423 |
return ( $marc_flavour eq 'UNIMARC' ) ? ( '700', 'a', '4' ) : ( '100', 'a', 'e' ); |
424 |
} |
425 |
|
426 |
sub get_auth_author_field { |
427 |
my $marc_flavour = C4::Context->preference('marcflavour'); |
428 |
return ( $marc_flavour eq 'UNIMARC' ) ? ( '106', 'a' ) : ( '100', 'a' ); |
429 |
} |
430 |
|
373 |
sub create_title_field { |
431 |
sub create_title_field { |
374 |
my ( $title, $marcflavour ) = @_; |
432 |
my ( $title, $marcflavour ) = @_; |
375 |
|
433 |
|
Lines 401-422
sub create_issn_field {
Link Here
|
401 |
return $field; |
459 |
return $field; |
402 |
} |
460 |
} |
403 |
|
461 |
|
|
|
462 |
sub create_author_field { |
463 |
my ( $author ) = @_; |
464 |
|
465 |
my ( $author_field, $author_subfield, $author_relator_subfield ) = get_author_field(); |
466 |
my $field = MARC::Field->new( |
467 |
$author_field, '', '', |
468 |
$author_subfield => $author, |
469 |
$author_relator_subfield => 'aut' |
470 |
); |
471 |
|
472 |
return $field; |
473 |
} |
474 |
|
404 |
subtest 'MARC21' => sub { |
475 |
subtest 'MARC21' => sub { |
405 |
plan tests => 34; |
476 |
plan tests => 42; |
406 |
run_tests('MARC21'); |
477 |
run_tests('MARC21'); |
407 |
$schema->storage->txn_rollback; |
478 |
$schema->storage->txn_rollback; |
408 |
$schema->storage->txn_begin; |
479 |
$schema->storage->txn_begin; |
409 |
}; |
480 |
}; |
410 |
|
481 |
|
411 |
subtest 'UNIMARC' => sub { |
482 |
subtest 'UNIMARC' => sub { |
412 |
plan tests => 34; |
483 |
plan tests => 42; |
|
|
484 |
|
485 |
# Mock the auth type data for UNIMARC |
486 |
$dbh->do("UPDATE auth_types SET auth_tag_to_report = '106' WHERE auth_tag_to_report = '100'") or die $dbh->errstr; |
487 |
|
413 |
run_tests('UNIMARC'); |
488 |
run_tests('UNIMARC'); |
414 |
$schema->storage->txn_rollback; |
489 |
$schema->storage->txn_rollback; |
415 |
$schema->storage->txn_begin; |
490 |
$schema->storage->txn_begin; |
416 |
}; |
491 |
}; |
417 |
|
492 |
|
418 |
subtest 'NORMARC' => sub { |
493 |
subtest 'NORMARC' => sub { |
419 |
plan tests => 34; |
494 |
plan tests => 42; |
420 |
run_tests('NORMARC'); |
495 |
run_tests('NORMARC'); |
421 |
$schema->storage->txn_rollback; |
496 |
$schema->storage->txn_rollback; |
422 |
$schema->storage->txn_begin; |
497 |
$schema->storage->txn_begin; |
423 |
- |
|
|