3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test::More tests => 1;
24 use Koha::SearchEngine::Elasticsearch::QueryBuilder;
26 subtest 'build_authorities_query_compat() tests' => sub {
31 $qb = Koha::SearchEngine::Elasticsearch::QueryBuilder->new({ 'index' => 'authorities' }),
32 'Creating new query builder object for authorities'
35 my $koha_to_index_name = $Koha::SearchEngine::Elasticsearch::QueryBuilder::koha_to_index_name;
36 my $search_term = 'a';
38 foreach my $koha_name ( keys %{ $koha_to_index_name } ) {
39 my $query = $qb->build_authorities_query_compat( [ $koha_name ], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' );
40 if ( $koha_name eq 'all' ) {
41 is( $query->{query}->{bool}->{should}[0]->{match}->{_all},
44 is( $query->{query}->{bool}->{should}[0]->{match}->{$koha_to_index_name->{$koha_name}},
51 $qb->build_authorities_query_compat( [ 'tomas' ], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' );
53 'Koha::Exceptions::WrongParameter',
54 'Exception thrown on invalid value in the marclist param';