|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 18; |
20 |
use Test::More tests => 19; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
use List::MoreUtils qw( uniq ); |
23 |
use List::MoreUtils qw( uniq ); |
|
Lines 781-786
subtest 'ModBiblio called from linker test' => sub {
Link Here
|
| 781 |
is($called,0,"We didn't call to link bibs because from linker"); |
781 |
is($called,0,"We didn't call to link bibs because from linker"); |
| 782 |
}; |
782 |
}; |
| 783 |
|
783 |
|
|
|
784 |
subtest "LinkBibHeadingsToAuthorities tests" => sub { |
| 785 |
plan tests => 5; |
| 786 |
|
| 787 |
# Set up mocks to return more than 1 match |
| 788 |
my $biblio_mod = Test::MockModule->new( 'C4::Linker::Default' ); |
| 789 |
$biblio_mod->mock( 'get_link', sub { |
| 790 |
return (undef, undef, 2); |
| 791 |
}); |
| 792 |
# UNIMARC return values should be consistent with MARC21 |
| 793 |
# testing with MARC21 should be sufficient for now |
| 794 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
| 795 |
t::lib::Mocks::mock_preference('AutoCreateAuthorities', '0'); |
| 796 |
|
| 797 |
my $linker = C4::Linker::Default->new(); |
| 798 |
my $biblio = $builder->build_sample_biblio(); |
| 799 |
my $record = $biblio->metadata->record; |
| 800 |
|
| 801 |
# Generate a field, no current link |
| 802 |
my $field = MARC::Field->new('650','','','a' => 'Duplicated' ); |
| 803 |
|
| 804 |
$record->append_fields($field); |
| 805 |
my ( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $record, "", undef, 650, 1 ); |
| 806 |
is( $num_headings_changed, 0, 'We did not make any changes because we found 2' ); |
| 807 |
is_deeply( $results->{unlinked}, |
| 808 |
{"Duplicated" => 1 }, |
| 809 |
"The heading was not linked" |
| 810 |
); |
| 811 |
is_deeply( $results->{details}[0], |
| 812 |
{ |
| 813 |
tag => 650, |
| 814 |
authid => undef, |
| 815 |
status => 'MULTIPLE_MATCH', |
| 816 |
auth_type => 'TOPIC_TERM', |
| 817 |
tag_to_report => 150 |
| 818 |
}, |
| 819 |
"The heading was not linked" |
| 820 |
); |
| 821 |
|
| 822 |
t::lib::Mocks::mock_preference('AutoCreateAuthorities', '1'); |
| 823 |
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $record, "", undef, 650, 1 ); |
| 824 |
is( $num_headings_changed, 0, 'We did not make any changes because we found 2' ); |
| 825 |
is_deeply( $results->{details}[0], |
| 826 |
{ |
| 827 |
tag => 650, |
| 828 |
authid => undef, |
| 829 |
status => 'MULTIPLE_MATCH', |
| 830 |
auth_type => 'TOPIC_TERM', |
| 831 |
tag_to_report => 150 |
| 832 |
}, |
| 833 |
"When AutoCreateAuthorities is enabled, multiple results are reported" |
| 834 |
); |
| 835 |
|
| 836 |
}; |
| 837 |
|
| 784 |
subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { |
838 |
subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { |
| 785 |
plan tests => 12; |
839 |
plan tests => 12; |
| 786 |
|
840 |
|
| 787 |
- |
|
|