|
Lines 73-79
subtest "UNIMARC tests" => sub {
Link Here
|
| 73 |
|
73 |
|
| 74 |
subtest "_search tests" => sub { |
74 |
subtest "_search tests" => sub { |
| 75 |
|
75 |
|
| 76 |
plan tests => 11; |
76 |
plan tests => 15; |
| 77 |
|
77 |
|
| 78 |
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); |
78 |
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); |
| 79 |
t::lib::Mocks::mock_preference( 'SearchEngine', 'Elasticsearch' ); |
79 |
t::lib::Mocks::mock_preference( 'SearchEngine', 'Elasticsearch' ); |
|
Lines 93-98
subtest "_search tests" => sub {
Link Here
|
| 93 |
); |
93 |
); |
| 94 |
|
94 |
|
| 95 |
t::lib::Mocks::mock_preference( 'LinkerConsiderThesaurus', '0' ); |
95 |
t::lib::Mocks::mock_preference( 'LinkerConsiderThesaurus', '0' ); |
|
|
96 |
t::lib::Mocks::mock_preference( 'ConsiderHeadingUse', '0' ); |
| 96 |
|
97 |
|
| 97 |
my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' ); |
98 |
my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' ); |
| 98 |
my $heading = C4::Heading->new_from_field($field); |
99 |
my $heading = C4::Heading->new_from_field($field); |
|
Lines 271-276
subtest "_search tests" => sub {
Link Here
|
| 271 |
$matched_auths, $expected_result, |
272 |
$matched_auths, $expected_result, |
| 272 |
"When thesaurus in subfield 2, and nothing is found, we don't search again if LinkerConsiderThesaurus disabled" |
273 |
"When thesaurus in subfield 2, and nothing is found, we don't search again if LinkerConsiderThesaurus disabled" |
| 273 |
); |
274 |
); |
|
|
275 |
|
| 276 |
# return to the "original" mocked version of search_auth_compat: |
| 277 |
$search->mock( |
| 278 |
'search_auth_compat', |
| 279 |
sub { |
| 280 |
my $self = shift; |
| 281 |
my $search_query = shift; |
| 282 |
return ( $search_query, 1 ); |
| 283 |
} |
| 284 |
); |
| 285 |
t::lib::Mocks::mock_preference( 'ConsiderHeadingUse', '1' ); |
| 286 |
|
| 287 |
($search_query) = $heading->_search('match-heading'); |
| 288 |
$terms = $search_query->{query}->{bool}->{must}; |
| 289 |
$expected_terms = [ |
| 290 |
{ term => { 'match-heading.ci_raw' => 'Uncles generalsubdiv Fiction' } }, |
| 291 |
{ term => { 'heading-use-subject-added-entry.ci_raw' => 'a' } }, |
| 292 |
]; |
| 293 |
is_deeply( |
| 294 |
$terms, $expected_terms, |
| 295 |
"With ConsiderHeadingUse on and 650 tag Heading-use-subject-added-entry = 'a' is required in search query" |
| 296 |
); |
| 297 |
|
| 298 |
my $field_700 = MARC::Field->new( '700', '1', '2', a => 'Shakespeare William', t => 'Othello' ); |
| 299 |
my $heading_700 = C4::Heading->new_from_field($field_700); |
| 300 |
($search_query) = $heading_700->_search('match-heading'); |
| 301 |
$terms = $search_query->{query}->{bool}->{must}; |
| 302 |
$expected_terms = [ |
| 303 |
{ term => { 'match-heading.ci_raw' => 'Shakespeare William Othello' } }, |
| 304 |
{ term => { 'heading-use-main-or-added-entry.ci_raw' => 'a' } }, |
| 305 |
]; |
| 306 |
is_deeply( |
| 307 |
$terms, $expected_terms, |
| 308 |
"With ConsiderHeadingUse on and 700 tag Heading-use-main-or-added-entry = 'a' is required in search query" |
| 309 |
); |
| 310 |
|
| 311 |
my $field_800 = MARC::Field->new( '800', '1', ' ', a => 'Shakespeare William', t => 'Collected works' ); |
| 312 |
my $heading_800 = C4::Heading->new_from_field($field_800); |
| 313 |
($search_query) = $heading_800->_search('match-heading'); |
| 314 |
$terms = $search_query->{query}->{bool}->{must}; |
| 315 |
$expected_terms = [ |
| 316 |
{ term => { 'match-heading.ci_raw' => 'Shakespeare William Collected works' } }, |
| 317 |
{ term => { 'heading-use-series-added-entry.ci_raw' => 'a' } }, |
| 318 |
]; |
| 319 |
is_deeply( |
| 320 |
$terms, $expected_terms, |
| 321 |
"With ConsiderHeadingUse on and 800 tag Heading-use-series-added-entry = 'a' is required in search query" |
| 322 |
); |
| 323 |
|
| 324 |
t::lib::Mocks::mock_preference( 'ConsiderHeadingUse', '0' ); |
| 325 |
|
| 326 |
($search_query) = $heading_800->_search('match-heading'); |
| 327 |
$terms = $search_query->{query}->{bool}->{must}; |
| 328 |
$expected_terms = [ |
| 329 |
{ term => { 'match-heading.ci_raw' => 'Shakespeare William Collected works' } }, |
| 330 |
]; |
| 331 |
is_deeply( |
| 332 |
$terms, $expected_terms, |
| 333 |
"With ConsiderHeadingUse off and 800 tag there is no Heading-use-series-added-entry condition in search query" |
| 334 |
); |
| 274 |
}; |
335 |
}; |
| 275 |
|
336 |
|
| 276 |
subtest "authorities exact match tests" => sub { |
337 |
subtest "authorities exact match tests" => sub { |
| 277 |
- |
|
|