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

(-)a/t/db_dependent/Heading.t (-16 / +20 lines)
Lines 69-92 subtest "_search tests" => sub { Link Here
69
    t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch');
69
    t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch');
70
    my $search = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search');
70
    my $search = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search');
71
71
72
    $search->mock('search_auth_compat', sub {
72
    $search->mock(
73
        my $self = shift;
73
        'search_auth_compat',
74
        my $search_query = shift;
74
        sub {
75
        return $search_query;
75
            my $self         = shift;
76
    });
76
            my $search_query = shift;
77
77
            return $search_query;
78
    my $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,' );
78
        }
79
    my $heading = C4::Heading->new_from_field($field);
79
    );
80
    my $search_query = $heading->_search( 'match-heading' );
80
81
    my $terms = $search_query->{query}->{bool}->{must};
81
    my ( $field, $heading, $search_query, $terms );
82
83
    $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,' );
84
    $heading = C4::Heading->new_from_field($field);
85
    $search_query = $heading->_search( 'match-heading' );
86
    $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");
87
    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
88
84
89
85
    my $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,', e => '[author]' );
90
    $field = MARC::Field->new( '100', ' ', '', a => 'Yankovic, Al', d => '1959-,', e => '[author]' );
86
    my $heading = C4::Heading->new_from_field($field);
91
    $heading = C4::Heading->new_from_field($field);
87
    my $search_query = $heading->_search( 'match-heading' );
92
    $search_query = $heading->_search( 'match-heading' );
88
    my $terms = $search_query->{query}->{bool}->{must};
93
    $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");
94
    is_deeply( $terms->[0], { term => { 'match-heading.ci_raw' => 'Yankovic, Al 1959' } }, "Search formed as expected for a non-subject field with double punctuation, hyphen+comma");
90
95
91
    $field = MARC::Field->new( '100', ' ', '', a => 'Tolkien, J.R.R.,', e => '[author]' );
96
    $field = MARC::Field->new( '100', ' ', '', a => 'Tolkien, J.R.R.,', e => '[author]' );
92
    $heading = C4::Heading->new_from_field($field);
97
    $heading = C4::Heading->new_from_field($field);
93
- 

Return to bug 33100