Lines 6-14
Link Here
|
6 |
use strict; |
6 |
use strict; |
7 |
use warnings; |
7 |
use warnings; |
8 |
|
8 |
|
9 |
use Test::More tests => 4; |
9 |
use Test::MockModule; |
|
|
10 |
use Test::MockObject; |
11 |
use Test::More tests => 5; |
12 |
use t::lib::Mocks; |
10 |
use MARC::Record; |
13 |
use MARC::Record; |
11 |
|
14 |
|
|
|
15 |
use C4::AuthoritiesMarc qw( FindDuplicateAuthority ); |
16 |
|
12 |
BEGIN { |
17 |
BEGIN { |
13 |
use_ok('C4::AuthoritiesMarc::MARC21', qw( default_auth_type_location fix_marc21_auth_type_location )); |
18 |
use_ok('C4::AuthoritiesMarc::MARC21', qw( default_auth_type_location fix_marc21_auth_type_location )); |
14 |
} |
19 |
} |
Lines 19-21
ok($result[1] eq 'a', "testing default_auth_type_location has first value 'a'");
Link Here
|
19 |
|
24 |
|
20 |
my $marc_record = MARC::Record->new(); |
25 |
my $marc_record = MARC::Record->new(); |
21 |
is(C4::AuthoritiesMarc::MARC21::fix_marc21_auth_type_location($marc_record, '', ''), undef, "testing fix_marc21_auth_type_location returns undef with empty MARC record"); |
26 |
is(C4::AuthoritiesMarc::MARC21::fix_marc21_auth_type_location($marc_record, '', ''), undef, "testing fix_marc21_auth_type_location returns undef with empty MARC record"); |
22 |
- |
27 |
|
|
|
28 |
subtest "FindDuplicateAuthority tests" => sub { |
29 |
plan tests => 2; |
30 |
my $zebra_search_module = Test::MockModule->new( 'C4::Search' ); |
31 |
$zebra_search_module->mock( 'SimpleSearch', sub { |
32 |
my $query = shift; |
33 |
return ( undef, [$query] ); |
34 |
}); |
35 |
$zebra_search_module->mock( 'new_record_from_zebra', sub { |
36 |
my (undef, $query ) = @_; |
37 |
my $marc = MARC::Record->new; |
38 |
$marc->append_fields( |
39 |
MARC::Field->new( '001', $query ), |
40 |
); |
41 |
return $marc; |
42 |
}); |
43 |
my $es_search_module = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch::Search' ); |
44 |
$es_search_module->mock( 'simple_search_compat', sub { |
45 |
my (undef, $query) = @_; |
46 |
return ( undef, [$query] ); |
47 |
}); |
48 |
|
49 |
my $record = MARC::Record->new; |
50 |
$record->append_fields( |
51 |
MARC::Field->new('155', '', '', a => 'Potato' ), |
52 |
); |
53 |
|
54 |
t::lib::Mocks::mock_preference( 'SearchEngine', 'Zebra' ); |
55 |
my ($query) = FindDuplicateAuthority( $record, "GENRE/FORM" ); |
56 |
is( $query, q{at:"GENRE/FORM" AND he:"Potato"}, "Query formed correctly for Zebra"); |
57 |
|
58 |
t::lib::Mocks::mock_preference( 'SearchEngine', 'Elasticsearch' ); |
59 |
($query) = FindDuplicateAuthority( $record, "GENRE/FORM" ); |
60 |
is( $query, q{at:"GENRE/FORM" AND he:"Potato"}, "Query formed correctly for Elasticsearch"); |
61 |
|
62 |
}; |