|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 2; |
20 |
use Test::More tests => 3; |
| 21 |
|
21 |
|
| 22 |
use Koha::SearchEngine::Elasticsearch::QueryBuilder; |
22 |
use Koha::SearchEngine::Elasticsearch::QueryBuilder; |
| 23 |
|
23 |
|
|
Lines 83-86
subtest '_split_query() tests' => sub {
Link Here
|
| 83 |
is_deeply(\@res, \@exp, 'quoted search terms surrounded by spaces correctly'); |
83 |
is_deeply(\@res, \@exp, 'quoted search terms surrounded by spaces correctly'); |
| 84 |
}; |
84 |
}; |
| 85 |
|
85 |
|
| 86 |
1; |
86 |
subtest '_clean_search_term() tests' => sub { |
|
|
87 |
plan tests => 10; |
| 88 |
|
| 89 |
my $qb; |
| 90 |
ok( |
| 91 |
$qb = Koha::SearchEngine::Elasticsearch::QueryBuilder->new({ 'index' => $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX }), |
| 92 |
'Creating a new QueryBuilder object' |
| 93 |
); |
| 94 |
|
| 95 |
my $res = $qb->_clean_search_term('an=123'); |
| 96 |
is($res, 'an:123', 'equals sign replaced with colon'); |
| 97 |
|
| 98 |
$res = $qb->_clean_search_term('"balanced quotes"'); |
| 99 |
is($res, '"balanced quotes"', 'balanced quotes returned correctly'); |
| 100 |
|
| 101 |
$res = $qb->_clean_search_term('unbalanced quotes"'); |
| 102 |
is($res, 'unbalanced quotes ', 'unbalanced quotes removed'); |
| 103 |
|
| 104 |
$res = $qb->_clean_search_term('"unbalanced "quotes"'); |
| 105 |
is($res, ' unbalanced quotes ', 'unbalanced quotes removed'); |
| 106 |
|
| 107 |
$res = $qb->_clean_search_term('test : query'); |
| 108 |
is($res, 'test query', 'dangling colon removed'); |
| 109 |
|
| 110 |
$res = $qb->_clean_search_term('test :: query'); |
| 111 |
is($res, 'test query', 'dangling double colon removed'); |
| 112 |
|
| 113 |
$res = $qb->_clean_search_term('test "another : query"'); |
| 114 |
is($res, 'test "another : query"', 'quoted dangling colon not removed'); |
| 115 |
|
| 116 |
$res = $qb->_clean_search_term('test {another part}'); |
| 117 |
is($res, 'test "another part"', 'curly brackets replaced correctly'); |
| 118 |
|
| 119 |
$res = $qb->_clean_search_term('test {another part'); |
| 120 |
is($res, 'test another part', 'unbalanced curly brackets replaced correctly'); |
| 121 |
}; |
| 122 |
|
| 123 |
1; |
| 87 |
- |
|
|