View | Details | Raw Unified | Return to bug 33296
Collapse All | Expand All

(-)a/t/db_dependent/Heading.t (-2 / +54 lines)
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 => 10;
68
    plan tests => 14;
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 85-90 subtest "_search tests" => sub { Link Here
85
    );
85
    );
86
86
87
    t::lib::Mocks::mock_preference( 'LinkerConsiderThesaurus', '0' );
87
    t::lib::Mocks::mock_preference( 'LinkerConsiderThesaurus', '0' );
88
    t::lib::Mocks::mock_preference( 'ConsiderHeadingUse',      '0' );
88
89
89
    my $field          = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' );
90
    my $field          = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' );
90
    my $heading        = C4::Heading->new_from_field($field);
91
    my $heading        = C4::Heading->new_from_field($field);
Lines 218-221 subtest "_search tests" => sub { Link Here
218
        "When thesaurus in subfield 2, and nothing is found, we don't search again if LinkerConsiderThesaurusDisabled"
219
        "When thesaurus in subfield 2, and nothing is found, we don't search again if LinkerConsiderThesaurusDisabled"
219
    );
220
    );
220
221
222
    t::lib::Mocks::mock_preference( 'ConsiderHeadingUse', '1' );
223
224
    ($search_query) = $heading->_search('match-heading');
225
    $terms          = $search_query->{query}->{bool}->{must};
226
    $expected_terms = [
227
        { term => { 'match-heading.ci_raw'                   => 'Uncles generalsubdiv Fiction' } },
228
        { term => { 'heading-use-subject-added-entry.ci_raw' => 'a' } },
229
    ];
230
    is_deeply(
231
        $terms, $expected_terms,
232
        "With ConsiderHeadingUse on and 650 tag Heading-use-subject-added-entry = 'a' is required in search query"
233
    );
234
    use Data::Dumper;
235
236
    my $field_700   = MARC::Field->new( '700', '1', '2', a => 'Shakespeare William', t => 'Othello' );
237
    my $heading_700 = C4::Heading->new_from_field($field_700);
238
    ($search_query) = $heading_700->_search('match-heading');
239
    $terms          = $search_query->{query}->{bool}->{must};
240
    $expected_terms = [
241
        { term => { 'match-heading.ci_raw'                   => 'Shakespeare William Othello' } },
242
        { term => { 'heading-use-main-or-added-entry.ci_raw' => 'a' } },
243
    ];
244
    is_deeply(
245
        $terms, $expected_terms,
246
        "With ConsiderHeadingUse on and 700 tag Heading-use-main-or-added-entry = 'a' is required in search query"
247
    );
248
249
    my $field_800   = MARC::Field->new( '800', '1', ' ', a => 'Shakespeare William', t => 'Collected works' );
250
    my $heading_800 = C4::Heading->new_from_field($field_800);
251
    ($search_query) = $heading_800->_search('match-heading');
252
    $terms          = $search_query->{query}->{bool}->{must};
253
    $expected_terms = [
254
        { term => { 'match-heading.ci_raw'                  => 'Shakespeare William Collected works' } },
255
        { term => { 'heading-use-series-added-entry.ci_raw' => 'a' } },
256
    ];
257
    is_deeply(
258
        $terms, $expected_terms,
259
        "With ConsiderHeadingUse on and 800 tag Heading-use-series-added-entry = 'a' is required in search query"
260
    );
261
262
    t::lib::Mocks::mock_preference( 'ConsiderHeadingUse', '0' );
263
264
    ($search_query) = $heading_800->_search('match-heading');
265
    $terms          = $search_query->{query}->{bool}->{must};
266
    $expected_terms = [
267
        { term => { 'match-heading.ci_raw' => 'Shakespeare William Collected works' } },
268
    ];
269
    is_deeply(
270
        $terms, $expected_terms,
271
        "With ConsiderHeadingUse off and 800 tag there is no Heading-use-series-added-entry condition in search query"
272
    );
273
221
};
274
};
222
- 

Return to bug 33296