Lines 85-91
$se->mock(
Link Here
|
85 |
|
85 |
|
86 |
subtest 'build_authorities_query_compat() tests' => sub { |
86 |
subtest 'build_authorities_query_compat() tests' => sub { |
87 |
|
87 |
|
88 |
plan tests => 72; |
88 |
plan tests => 81; |
89 |
|
89 |
|
90 |
my $qb; |
90 |
my $qb; |
91 |
|
91 |
|
Lines 94-101
subtest 'build_authorities_query_compat() tests' => sub {
Link Here
|
94 |
'Creating new query builder object for authorities' |
94 |
'Creating new query builder object for authorities' |
95 |
); |
95 |
); |
96 |
|
96 |
|
|
|
97 |
my $koha_name = 'any'; |
98 |
my $search_term = 'a'; |
99 |
my $query = $qb->build_authorities_query_compat( |
100 |
[$koha_name], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', |
101 |
'asc' |
102 |
); |
103 |
ok( !defined $query->{query}->{bool}->{should}, "Should query not used if 'and_or' not passed" ); |
104 |
ok( defined $query->{query}->{bool}->{must}, "Must query used if 'and_or' not passed" ); |
105 |
is( $query->{query}->{bool}->{must}[0]->{query_string}->{query}, "a*" ); |
106 |
$query = $qb->build_authorities_query_compat( |
107 |
[$koha_name], ['and'], undef, ['contains'], [$search_term], 'AUTH_TYPE', |
108 |
'asc' |
109 |
); |
110 |
ok( !defined $query->{query}->{bool}->{should}, "Should query not used when 'and_or' passed 'and'" ); |
111 |
ok( defined $query->{query}->{bool}->{must}, "Must query used when 'and_or' passed 'and'" ); |
112 |
is( $query->{query}->{bool}->{must}[0]->{query_string}->{query}, "a*" ); |
113 |
$query = $qb->build_authorities_query_compat( |
114 |
[$koha_name], ['or'], undef, ['contains'], [$search_term], 'AUTH_TYPE', |
115 |
'asc' |
116 |
); |
117 |
ok( defined $query->{query}->{bool}->{should}, "Should query used if 'and_or' passed 'or'" ); |
118 |
ok( defined $query->{query}->{bool}->{should}, "Must query not used if 'and_or' passed 'or'" ); |
119 |
is( $query->{query}->{bool}->{should}[0]->{query_string}->{query}, "a*" ); |
120 |
|
97 |
my $koha_to_index_name = $Koha::SearchEngine::Elasticsearch::QueryBuilder::koha_to_index_name; |
121 |
my $koha_to_index_name = $Koha::SearchEngine::Elasticsearch::QueryBuilder::koha_to_index_name; |
98 |
my $search_term = 'a'; |
122 |
$search_term = 'a'; |
99 |
foreach my $koha_name ( keys %{$koha_to_index_name} ) { |
123 |
foreach my $koha_name ( keys %{$koha_to_index_name} ) { |
100 |
my $query = $qb->build_authorities_query_compat( |
124 |
my $query = $qb->build_authorities_query_compat( |
101 |
[$koha_name], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', |
125 |
[$koha_name], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', |
102 |
- |
|
|