|
Lines 105-111
$se->mock( 'get_elasticsearch_mappings', sub {
Link Here
|
| 105 |
|
105 |
|
| 106 |
subtest 'build_authorities_query_compat() tests' => sub { |
106 |
subtest 'build_authorities_query_compat() tests' => sub { |
| 107 |
|
107 |
|
| 108 |
plan tests => 72; |
108 |
plan tests => 81; |
| 109 |
|
109 |
|
| 110 |
my $qb; |
110 |
my $qb; |
| 111 |
|
111 |
|
|
Lines 114-121
subtest 'build_authorities_query_compat() tests' => sub {
Link Here
|
| 114 |
'Creating new query builder object for authorities' |
114 |
'Creating new query builder object for authorities' |
| 115 |
); |
115 |
); |
| 116 |
|
116 |
|
| 117 |
my $koha_to_index_name = $Koha::SearchEngine::Elasticsearch::QueryBuilder::koha_to_index_name; |
117 |
my $koha_name = 'any'; |
| 118 |
my $search_term = 'a'; |
118 |
my $search_term = 'a'; |
|
|
119 |
my $query = $qb->build_authorities_query_compat( |
| 120 |
[$koha_name], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', |
| 121 |
'asc' |
| 122 |
); |
| 123 |
ok( !defined $query->{query}->{bool}->{should}, "Should query not used if 'and_or' not passed" ); |
| 124 |
ok( defined $query->{query}->{bool}->{must}, "Must query used if 'and_or' not passed" ); |
| 125 |
is( $query->{query}->{bool}->{must}[0]->{query_string}->{query}, "a*" ); |
| 126 |
$query = $qb->build_authorities_query_compat( |
| 127 |
[$koha_name], ['and'], undef, ['contains'], [$search_term], 'AUTH_TYPE', |
| 128 |
'asc' |
| 129 |
); |
| 130 |
ok( !defined $query->{query}->{bool}->{should}, "Should query not used when 'and_or' passed 'and'" ); |
| 131 |
ok( defined $query->{query}->{bool}->{must}, "Must query used when 'and_or' passed 'and'" ); |
| 132 |
is( $query->{query}->{bool}->{must}[0]->{query_string}->{query}, "a*" ); |
| 133 |
$query = $qb->build_authorities_query_compat( |
| 134 |
[$koha_name], ['or'], undef, ['contains'], [$search_term], 'AUTH_TYPE', |
| 135 |
'asc' |
| 136 |
); |
| 137 |
ok( defined $query->{query}->{bool}->{should}, "Should query used if 'and_or' passed 'or'" ); |
| 138 |
ok( defined $query->{query}->{bool}->{should}, "Must query not used if 'and_or' passed 'or'" ); |
| 139 |
is( $query->{query}->{bool}->{should}[0]->{query_string}->{query}, "a*" ); |
| 140 |
|
| 141 |
my $koha_to_index_name = $Koha::SearchEngine::Elasticsearch::QueryBuilder::koha_to_index_name; |
| 142 |
$search_term = 'a'; |
| 119 |
foreach my $koha_name ( keys %{ $koha_to_index_name } ) { |
143 |
foreach my $koha_name ( keys %{ $koha_to_index_name } ) { |
| 120 |
my $query = $qb->build_authorities_query_compat( [ $koha_name ], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' ); |
144 |
my $query = $qb->build_authorities_query_compat( [ $koha_name ], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' ); |
| 121 |
if ( $koha_name eq 'all' || $koha_name eq 'any' ) { |
145 |
if ( $koha_name eq 'all' || $koha_name eq 'any' ) { |
| 122 |
- |
|
|