Lines 187-193
subtest '_split_query() tests' => sub {
Link Here
|
187 |
}; |
187 |
}; |
188 |
|
188 |
|
189 |
subtest '_clean_search_term() tests' => sub { |
189 |
subtest '_clean_search_term() tests' => sub { |
190 |
plan tests => 13; |
190 |
plan tests => 15; |
191 |
|
191 |
|
192 |
my $qb; |
192 |
my $qb; |
193 |
ok( |
193 |
ok( |
Lines 219-230
subtest '_clean_search_term() tests' => sub {
Link Here
|
219 |
$res = $qb->_clean_search_term('test [123 TO 345]'); |
219 |
$res = $qb->_clean_search_term('test [123 TO 345]'); |
220 |
is($res, 'test [123 TO 345]', 'keep inculsive range untouched'); |
220 |
is($res, 'test [123 TO 345]', 'keep inculsive range untouched'); |
221 |
|
221 |
|
222 |
$res = $qb->_clean_search_term('test [test TO TEST} [and] {123 TO 456]'); |
222 |
$res = $qb->_clean_search_term('test [test TO TEST} ["[and] {123 TO 456]" "[balanced]"]'); |
223 |
is($res, 'test [test TO TEST} \[and\] {123 TO 456]', 'keep exclusive range untouched'); |
223 |
is($res, 'test [test TO TEST} \["[and] {123 TO 456]" "[balanced]"\]', 'keep exclusive range untouched'); |
224 |
|
224 |
|
225 |
$res = $qb->_clean_search_term('test[]test TO TEST] [ {123 to 345}}'); |
225 |
$res = $qb->_clean_search_term('test[]test TO TEST] [ {123 to 345}}'); |
226 |
is($res, 'test\[\]test TO TEST\] \[ \{123 to 345\}\}', 'screen all square and curly brackets'); |
226 |
is($res, 'test\[\]test TO TEST\] \[ \{123 to 345\}\}', 'screen all square and curly brackets'); |
227 |
|
227 |
|
|
|
228 |
t::lib::Mocks::mock_preference('QueryRegexEscapeOptions', 'escape'); |
229 |
|
230 |
$res = $qb->_clean_search_term('test inside regexps /this [a-z]/ and \/not [a-z]\/ and that [a-z] [a TO z]'); |
231 |
is($res, 'test inside regexps \/this \[a-z\]\/ and \/not \[a-z\]\/ and that \[a-z\] [a TO z]', 'test inside regexps with QueryRegexEscapeOptions parameter set to escape'); |
232 |
|
233 |
t::lib::Mocks::mock_preference('QueryRegexEscapeOptions', 'dont_escape'); |
234 |
|
235 |
$res = $qb->_clean_search_term('test inside regexps /this [a-z]/ /this2 [a-z]/ [but] /this3 [a-z]/ and \/not [a-z]\/ and that [a-z] [a TO z]'); |
236 |
is($res, 'test inside regexps /this [a-z]/ /this2 [a-z]/ \[but\] /this3 [a-z]/ and \/not \[a-z\]\/ and that \[a-z\] [a TO z]', 'test inside regexps with QueryRegexEscapeOptions parameter set to dont_escape'); |
237 |
|
228 |
$res = $qb->_clean_search_term('ti:test AND kw:test'); |
238 |
$res = $qb->_clean_search_term('ti:test AND kw:test'); |
229 |
is($res, 'title:test AND test', 'ti converted to title, kw converted to empty string, dangling colon removed with space preserved'); |
239 |
is($res, 'title:test AND test', 'ti converted to title, kw converted to empty string, dangling colon removed with space preserved'); |
230 |
|
240 |
|
231 |
- |
|
|