Lines 20-30
use Modern::Perl;
Link Here
|
20 |
use Test::More tests => 2; |
20 |
use Test::More tests => 2; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use t::lib::Mocks; |
22 |
use t::lib::Mocks; |
|
|
23 |
use Encode qw( encode ); |
24 |
use MIME::Base64 qw( encode_base64 ); |
23 |
|
25 |
|
24 |
use_ok('Koha::SearchEngine::Elasticsearch::Search'); |
26 |
use_ok('Koha::SearchEngine::Elasticsearch::Search'); |
25 |
|
27 |
|
26 |
subtest 'search_auth_compat' => sub { |
28 |
subtest 'search_auth_compat' => sub { |
27 |
plan tests => 4; |
29 |
plan tests => 7; |
28 |
|
30 |
|
29 |
t::lib::Mocks::mock_preference( 'QueryRegexEscapeOptions', 'dont_escape' ); |
31 |
t::lib::Mocks::mock_preference( 'QueryRegexEscapeOptions', 'dont_escape' ); |
30 |
t::lib::Mocks::mock_preference( 'SearchEngine', 'Elasticsearch' ); |
32 |
t::lib::Mocks::mock_preference( 'SearchEngine', 'Elasticsearch' ); |
Lines 65-70
subtest 'search_auth_compat' => sub {
Link Here
|
65 |
$marc_record->append_fields( |
67 |
$marc_record->append_fields( |
66 |
MARC::Field->new( '001', 'Wrong001Number' ), |
68 |
MARC::Field->new( '001', 'Wrong001Number' ), |
67 |
); |
69 |
); |
|
|
70 |
$marc_record->append_fields( |
71 |
MARC::Field->new( '008', '100803n||a| nnaban |a aaa |d' ), |
72 |
); |
73 |
my $marc_data = encode_base64( encode( 'UTF-8', $marc_record->as_usmarc() ) ); |
68 |
return { |
74 |
return { |
69 |
hits => { |
75 |
hits => { |
70 |
hits => [ |
76 |
hits => [ |
Lines 72-78
subtest 'search_auth_compat' => sub {
Link Here
|
72 |
'_id' => 8675309, |
78 |
'_id' => 8675309, |
73 |
'_source' => { |
79 |
'_source' => { |
74 |
'local-number' => ['Wrong001Number'], |
80 |
'local-number' => ['Wrong001Number'], |
75 |
'marc_data' => $marc_record, |
81 |
'marc_data' => $marc_data, |
76 |
'marc_format' => 'base64ISO2709', |
82 |
'marc_format' => 'base64ISO2709', |
77 |
}, |
83 |
}, |
78 |
} |
84 |
} |
Lines 82-91
subtest 'search_auth_compat' => sub {
Link Here
|
82 |
} |
88 |
} |
83 |
); |
89 |
); |
84 |
|
90 |
|
|
|
91 |
t::lib::Mocks::mock_preference( 'ShowHeadingUse', 1 ); |
85 |
my ( $results, undef ) = $search->search_auth_compat('faked'); |
92 |
my ( $results, undef ) = $search->search_auth_compat('faked'); |
86 |
|
93 |
|
87 |
is( @$results[0]->{authid}, '8675309', 'We get the expected record _id and not the 001' ); |
94 |
is( @$results[0]->{authid}, '8675309', 'We get the expected record _id and not the 001' ); |
88 |
|
95 |
|
|
|
96 |
is( @$results[0]->{main}, 1, 'Valid main heading with ShowHeadingUse' ); |
97 |
is( |
98 |
@$results[0]->{subject}, |
99 |
undef, 'Valid main heading with ShowHeadingUse' |
100 |
); |
101 |
is( @$results[0]->{series}, 1, 'Valid main heading with ShowHeadingUse' ); |
89 |
}; |
102 |
}; |
90 |
|
103 |
|
91 |
1; |
104 |
1; |
92 |
- |
|
|