Lines 18-24
Link Here
|
18 |
use strict; |
18 |
use strict; |
19 |
use warnings; |
19 |
use warnings; |
20 |
|
20 |
|
21 |
use Test::More tests => 3; |
21 |
use Test::More tests => 4; |
22 |
|
22 |
|
23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
24 |
|
24 |
|
Lines 60-63
subtest "UNIMARC tests" => sub {
Link Here
|
60 |
ok(!C4::Heading::valid_heading_subfield('600', 'i'), '600i not valid for bib'); |
60 |
ok(!C4::Heading::valid_heading_subfield('600', 'i'), '600i not valid for bib'); |
61 |
|
61 |
|
62 |
ok(!C4::Heading::valid_heading_subfield('012', 'a'), '012a invalid field for bib'); |
62 |
ok(!C4::Heading::valid_heading_subfield('012', 'a'), '012a invalid field for bib'); |
63 |
} |
63 |
}; |
|
|
64 |
|
65 |
subtest "_search tests" => sub { |
66 |
plan tests => 3; |
67 |
|
68 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
69 |
t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch'); |
70 |
my $search = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search'); |
71 |
|
72 |
$search->mock('search_auth_compat', sub { |
73 |
my $self = shift; |
74 |
my $search_query = shift; |
75 |
return $search_query; |
76 |
}); |
77 |
|
78 |
my $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,' ); |
79 |
my $heading = C4::Heading->new_from_field($field); |
80 |
my $search_query = $heading->_search( 'match-heading' ); |
81 |
my $terms = $search_query->{query}->{bool}->{must}; |
82 |
is_deeply( $terms->[0], { term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } }, "Search formed as expected for a non-subject field with single punctuation mark"); |
83 |
|
84 |
|
85 |
my $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,', e => '[author]' ); |
86 |
my $heading = C4::Heading->new_from_field($field); |
87 |
my $search_query = $heading->_search( 'match-heading' ); |
88 |
my $terms = $search_query->{query}->{bool}->{must}; |
89 |
is_deeply( $terms->[0], { term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } }, "Search formed as expected for a non-subject field with doulbe punctuation, hyphen+comma"); |
90 |
|
91 |
$field = MARC::Field->new( '100', ' ', '', a => 'Tolkien, J.R.R.,', e => '[author]' ); |
92 |
$heading = C4::Heading->new_from_field($field); |
93 |
$search_query = $heading->_search( 'match-heading' ); |
94 |
$terms = $search_query->{query}->{bool}->{must}; |
95 |
is_deeply( $terms->[0], { term => { 'match-heading.ci_raw' => 'Tolkien, J.R.R' } }, "Search formed as expected for a non-subject field with double punctuation, period+comma "); |
96 |
|
97 |
}; |
64 |
- |
|
|