Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 5; |
20 |
use Test::More tests => 6; |
21 |
use t::lib::Mocks; |
21 |
use t::lib::Mocks; |
22 |
|
22 |
|
23 |
use_ok('Koha::SearchEngine::Elasticsearch::QueryBuilder'); |
23 |
use_ok('Koha::SearchEngine::Elasticsearch::QueryBuilder'); |
Lines 223-226
subtest '_clean_search_term() tests' => sub {
Link Here
|
223 |
is($res, 'test another part', 'unbalanced curly brackets replaced correctly'); |
223 |
is($res, 'test another part', 'unbalanced curly brackets replaced correctly'); |
224 |
}; |
224 |
}; |
225 |
|
225 |
|
|
|
226 |
subtest '_join_queries' => sub { |
227 |
plan tests => 6; |
228 |
|
229 |
my $params = { |
230 |
index => $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX, |
231 |
}; |
232 |
my $qb = Koha::SearchEngine::Elasticsearch::QueryBuilder->new($params); |
233 |
|
234 |
my $query; |
235 |
|
236 |
$query = $qb->_join_queries('foo'); |
237 |
is($query, 'foo', 'should work with a single param'); |
238 |
|
239 |
$query = $qb->_join_queries(undef, '', 'foo', '', undef); |
240 |
is($query, 'foo', 'should ignore undef or empty queries'); |
241 |
|
242 |
$query = $qb->_join_queries('foo', 'bar'); |
243 |
is($query, '(foo) AND (bar)', 'should join queries with an AND'); |
244 |
|
245 |
$query = $qb->_join_queries('homebranch:foo', 'onloan:false'); |
246 |
is($query, '(homebranch:foo) AND (onloan:false)', 'should also work when field is specified'); |
247 |
|
248 |
$query = $qb->_join_queries('homebranch:foo', 'mc-itype:BOOK', 'mc-itype:EBOOK'); |
249 |
is($query, '(homebranch:foo) AND itype:(BOOK OR EBOOK)', 'should join with OR when using an "mc-" field'); |
250 |
|
251 |
$query = $qb->_join_queries('homebranch:foo', 'mc-itype:BOOK', 'mc-itype:EBOOK', 'mc-location:SHELF'); |
252 |
is($query, '(homebranch:foo) AND itype:(BOOK OR EBOOK) AND location:(SHELF)', 'should join "mc-" parts with AND if not the same field'); |
253 |
}; |
254 |
|
226 |
1; |
255 |
1; |
227 |
- |
|
|