View | Details | Raw Unified | Return to bug 25189
Collapse All | Expand All

(-)a/t/db_dependent/Biblio.t (-5 / +32 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 13;
20
use Test::More tests => 14;
21
use Test::MockModule;
21
use Test::MockModule;
22
use List::MoreUtils qw( uniq );
22
use List::MoreUtils qw( uniq );
23
use MARC::Record;
23
use MARC::Record;
Lines 29-34 use Koha::Database; Link Here
29
use Koha::Caches;
29
use Koha::Caches;
30
use Koha::MarcSubfieldStructures;
30
use Koha::MarcSubfieldStructures;
31
31
32
use C4::Linker::Default;
33
32
BEGIN {
34
BEGIN {
33
    use_ok('C4::Biblio');
35
    use_ok('C4::Biblio');
34
}
36
}
Lines 124-129 subtest "GetMarcFromKohaField" => sub { Link Here
124
    is( $retval[0].$retval[1], '399a', 'Including 399a' );
126
    is( $retval[0].$retval[1], '399a', 'Including 399a' );
125
};
127
};
126
128
129
subtest "Authority creation with default linker" => sub {
130
    plan tests => 2;
131
    # Automatic authority creation
132
    t::lib::Mocks::mock_preference('LinkerModule', 'Default');
133
    t::lib::Mocks::mock_preference('BiblioAddsAuthorities', 1);
134
    t::lib::Mocks::mock_preference('AutoCreateAuthorities', 1);
135
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
136
    my $linker = C4::Linker::Default->new({});
137
    my $authorities_mod = Test::MockModule->new( 'C4::Heading' );
138
    $authorities_mod->mock(
139
        'authorities',
140
        sub {
141
            my $results = [{ authid => 'original' },{ authid => 'duplicate' }];
142
            return $results;
143
        }
144
    );
145
    my $marc_record = MARC::Record->new();
146
    my $field = MARC::Field->new(655, ' ', ' ','a' => 'Magical realism');
147
    $marc_record->append_fields( $field );
148
    my ($num_changed,$results) = LinkBibHeadingsToAuthorities($linker, $marc_record, "",undef);
149
    is( $num_changed, 0, "We shouldn't link or create a new record");
150
    ok( !defined $results->{added}, "If we have multiple matches, we shouldn't create a new record");
151
};
152
153
154
127
# Mocking variables
155
# Mocking variables
128
my $biblio_module = new Test::MockModule('C4::Biblio');
156
my $biblio_module = new Test::MockModule('C4::Biblio');
129
$biblio_module->mock(
157
$biblio_module->mock(
Lines 384-395 sub run_tests { Link Here
384
    # Automatic authority creation
412
    # Automatic authority creation
385
    t::lib::Mocks::mock_preference('BiblioAddsAuthorities', 1);
413
    t::lib::Mocks::mock_preference('BiblioAddsAuthorities', 1);
386
    t::lib::Mocks::mock_preference('AutoCreateAuthorities', 1);
414
    t::lib::Mocks::mock_preference('AutoCreateAuthorities', 1);
387
    my $authorities_mod = Test::MockModule->new( 'C4::AuthoritiesMarc' );
415
    my $authorities_mod = Test::MockModule->new( 'C4::Heading' );
388
    $authorities_mod->mock(
416
    $authorities_mod->mock(
389
        'SearchAuthorities',
417
        'authorities',
390
        sub {
418
        sub {
391
            my @results;
419
            my @results;
392
            return \@results, 0;
420
            return \@results;
393
        }
421
        }
394
    );
422
    );
395
    $success = 0;
423
    $success = 0;
396
- 

Return to bug 25189