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

(-)a/t/db_dependent/Heading.t (-3 / +55 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 80-86 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
    t::lib::Mocks::mock_preference( 'LinkerConsiderThesaurus', '0' );
84
    t::lib::Mocks::mock_preference( 'ConsiderHeadingUse',      '0' );
84
85
85
    my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' );
86
    my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' );
86
    my $heading = C4::Heading->new_from_field($field);
87
    my $heading = C4::Heading->new_from_field($field);
Lines 194-197 subtest "_search tests" => sub { Link Here
194
    ];
195
    ];
195
    is_deeply( $terms, $expected_terms, "When thesaurus in subfield 2, and nothing is found, we don't search again if LinkerConsiderThesaurusDisabled");
196
    is_deeply( $terms, $expected_terms, "When thesaurus in subfield 2, and nothing is found, we don't search again if LinkerConsiderThesaurusDisabled");
196
197
198
    t::lib::Mocks::mock_preference( 'ConsiderHeadingUse', '1' );
199
200
    ($search_query) = $heading->_search('match-heading');
201
    $terms          = $search_query->{query}->{bool}->{must};
202
    $expected_terms = [
203
        { term => { 'match-heading.ci_raw'                   => 'Uncles generalsubdiv Fiction' } },
204
        { term => { 'heading-use-subject-added-entry.ci_raw' => 'a' } },
205
    ];
206
    is_deeply(
207
        $terms, $expected_terms,
208
        "With ConsiderHeadingUse on and 650 tag Heading-use-subject-added-entry = 'a' is required in search query"
209
    );
210
    use Data::Dumper;
211
212
    my $field_700   = MARC::Field->new( '700', '1', '2', a => 'Shakespeare William', t => 'Othello' );
213
    my $heading_700 = C4::Heading->new_from_field($field_700);
214
    ($search_query) = $heading_700->_search('match-heading');
215
    $terms          = $search_query->{query}->{bool}->{must};
216
    $expected_terms = [
217
        { term => { 'match-heading.ci_raw'                   => 'Shakespeare William Othello' } },
218
        { term => { 'heading-use-main-or-added-entry.ci_raw' => 'a' } },
219
    ];
220
    is_deeply(
221
        $terms, $expected_terms,
222
        "With ConsiderHeadingUse on and 700 tag Heading-use-main-or-added-entry = 'a' is required in search query"
223
    );
224
225
    my $field_800   = MARC::Field->new( '800', '1', ' ', a => 'Shakespeare William', t => 'Collected works' );
226
    my $heading_800 = C4::Heading->new_from_field($field_800);
227
    ($search_query) = $heading_800->_search('match-heading');
228
    $terms          = $search_query->{query}->{bool}->{must};
229
    $expected_terms = [
230
        { term => { 'match-heading.ci_raw'                  => 'Shakespeare William Collected works' } },
231
        { term => { 'heading-use-series-added-entry.ci_raw' => 'a' } },
232
    ];
233
    is_deeply(
234
        $terms, $expected_terms,
235
        "With ConsiderHeadingUse on and 800 tag Heading-use-series-added-entry = 'a' is required in search query"
236
    );
237
238
    t::lib::Mocks::mock_preference( 'ConsiderHeadingUse', '0' );
239
240
    ($search_query) = $heading_800->_search('match-heading');
241
    $terms          = $search_query->{query}->{bool}->{must};
242
    $expected_terms = [
243
        { term => { 'match-heading.ci_raw' => 'Shakespeare William Collected works' } },
244
    ];
245
    is_deeply(
246
        $terms, $expected_terms,
247
        "With ConsiderHeadingUse off and 800 tag there is no Heading-use-series-added-entry condition in search query"
248
    );
249
197
};
250
};
198
- 

Return to bug 33296