|
Lines 65-71
subtest "UNIMARC tests" => sub {
Link Here
|
| 65 |
|
65 |
|
| 66 |
subtest "_search tests" => sub { |
66 |
subtest "_search tests" => sub { |
| 67 |
|
67 |
|
| 68 |
plan tests => 8; |
68 |
plan tests => 10; |
| 69 |
|
69 |
|
| 70 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
70 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
| 71 |
t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch'); |
71 |
t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch'); |
|
Lines 80-85
subtest "_search tests" => sub {
Link Here
|
| 80 |
return ($search_query, 1 ); |
80 |
return ($search_query, 1 ); |
| 81 |
}); |
81 |
}); |
| 82 |
|
82 |
|
|
|
83 |
t::lib::Mocks::mock_preference('LinkerConsiderThesaurus', '0'); |
| 83 |
|
84 |
|
| 84 |
my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' ); |
85 |
my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' ); |
| 85 |
my $heading = C4::Heading->new_from_field($field); |
86 |
my $heading = C4::Heading->new_from_field($field); |
|
Lines 87-92
subtest "_search tests" => sub {
Link Here
|
| 87 |
my $terms = $search_query->{query}->{bool}->{must}; |
88 |
my $terms = $search_query->{query}->{bool}->{must}; |
| 88 |
my $expected_terms = [ |
89 |
my $expected_terms = [ |
| 89 |
{ term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } }, |
90 |
{ term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } }, |
|
|
91 |
]; |
| 92 |
is_deeply( $terms, $expected_terms, "Search formed only using heading content, not thesaurus, when LinkerConsiderThesaurus disabled"); |
| 93 |
|
| 94 |
|
| 95 |
t::lib::Mocks::mock_preference('LinkerConsiderThesaurus', '1'); |
| 96 |
|
| 97 |
$field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' ); |
| 98 |
$heading = C4::Heading->new_from_field($field); |
| 99 |
($search_query) = $heading->_search( 'match-heading' ); |
| 100 |
$terms = $search_query->{query}->{bool}->{must}; |
| 101 |
$expected_terms = [ |
| 102 |
{ term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } }, |
| 90 |
{ term => { 'subject-heading-thesaurus.ci_raw' => 'a' } }, |
103 |
{ term => { 'subject-heading-thesaurus.ci_raw' => 'a' } }, |
| 91 |
]; |
104 |
]; |
| 92 |
is_deeply( $terms, $expected_terms, "Search formed as expected for a subject with second indicator 0"); |
105 |
is_deeply( $terms, $expected_terms, "Search formed as expected for a subject with second indicator 0"); |
|
Lines 151-157
subtest "_search tests" => sub {
Link Here
|
| 151 |
$search->mock('search_auth_compat', sub { |
164 |
$search->mock('search_auth_compat', sub { |
| 152 |
my $self = shift; |
165 |
my $self = shift; |
| 153 |
my $search_query = shift; |
166 |
my $search_query = shift; |
| 154 |
if( $search_query->{query}->{bool}->{must}[1]->{term}->{'subject-heading-thesaurus.ci_raw'} eq 'special_sauce' ){ |
167 |
if( |
|
|
168 |
scalar @{$search_query->{query}->{bool}->{must}} == 2 && |
| 169 |
$search_query->{query}->{bool}->{must}[1]->{term}->{'subject-heading-thesaurus.ci_raw'} eq 'special_sauce' |
| 170 |
){ |
| 155 |
return; |
171 |
return; |
| 156 |
} |
172 |
} |
| 157 |
return ($search_query, 1); |
173 |
return ($search_query, 1); |
|
Lines 168-171
subtest "_search tests" => sub {
Link Here
|
| 168 |
]; |
184 |
]; |
| 169 |
is_deeply( $terms, $expected_terms, "When thesaurus in subfield 2, and nothing is found, we should search again for notdefined (008_11 = z) "); |
185 |
is_deeply( $terms, $expected_terms, "When thesaurus in subfield 2, and nothing is found, we should search again for notdefined (008_11 = z) "); |
| 170 |
|
186 |
|
|
|
187 |
t::lib::Mocks::mock_preference('LinkerConsiderThesaurus', '0'); |
| 188 |
|
| 189 |
$search_query = undef; |
| 190 |
($search_query) = $heading->_search( 'match-heading' ); |
| 191 |
$terms = $search_query->{query}->{bool}->{must}; |
| 192 |
$expected_terms = [ |
| 193 |
{ term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } }, |
| 194 |
]; |
| 195 |
is_deeply( $terms, $expected_terms, "When thesaurus in subfield 2, and nothing is found, we don't search again if LinkerConsiderThesaurusDisabled"); |
| 196 |
|
| 171 |
}; |
197 |
}; |
| 172 |
- |
|
|