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

(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-3 / +26 lines)
Lines 17-27 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 1;
20
use Test::More tests => 2;
21
use Test::Exception;
21
use Test::Exception;
22
22
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
24
use Koha::SearchEngine::Elasticsearch::QueryBuilder
25
25
26
subtest 'build_authorities_query_compat() tests' => sub {
26
subtest 'build_authorities_query_compat() tests' => sub {
27
27
Lines 53-55 subtest 'build_authorities_query_compat() tests' => sub { Link Here
53
    'Koha::Exceptions::WrongParameter',
53
    'Koha::Exceptions::WrongParameter',
54
        'Exception thrown on invalid value in the marclist param';
54
        'Exception thrown on invalid value in the marclist param';
55
};
55
};
56
- 
56
57
subtest 'build query from form subtests' => sub {
58
    plan tests => 5;
59
60
    my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new({ 'index' => 'authorities' }),
61
    #when searching for authorities from a record the form returns marclist with blanks for unentered terms
62
    my @marclist = ('mainmainentry','mainentry','match', 'all');
63
    my @values   = ( undef,         'Hamilton',  undef,   undef);
64
    my @operator = ( 'contains', 'contains', 'contains', 'contains');
65
66
    my $query = $builder->build_authorities_query_compat( \@marclist, undef,
67
                    undef, \@operator , \@values, 'AUTH_TYPE', 'asc' );
68
    is($query->{query}->{bool}->{should}[0]->{match}->{'Heading'}, "Hamilton","Expected search is populated");
69
    is( scalar @{ $query->{query}->{bool}->{should} }, 1,"Only defined search is populated");
70
71
    @values[2] = 'Jefferson';
72
    $query = $builder->build_authorities_query_compat( \@marclist, undef,
73
                    undef, \@operator , \@values, 'AUTH_TYPE', 'asc' );
74
    is($query->{query}->{bool}->{should}[0]->{match}->{'Heading'}, "Hamilton","First index searched as expected");
75
    is($query->{query}->{bool}->{should}[1]->{match}->{'Match'}, "Jefferson","Second index searched when populated");
76
    is( scalar @{ $query->{query}->{bool}->{should} }, 2,"Only defined searches are populated");
77
78
79
};

Return to bug 19582