Lines 219-225
subtest 'build_authorities_query_compat() tests' => sub {
Link Here
|
219 |
}; |
219 |
}; |
220 |
|
220 |
|
221 |
subtest 'build_query tests' => sub { |
221 |
subtest 'build_query tests' => sub { |
222 |
plan tests => 60; |
222 |
plan tests => 63; |
223 |
|
223 |
|
224 |
my $qb; |
224 |
my $qb; |
225 |
|
225 |
|
Lines 406-411
subtest 'build_query tests' => sub {
Link Here
|
406 |
"all quoted strings are unaltered if more than one in query" |
406 |
"all quoted strings are unaltered if more than one in query" |
407 |
); |
407 |
); |
408 |
|
408 |
|
|
|
409 |
# Reset ESPreventAutoTruncate syspref |
410 |
t::lib::Mocks::mock_preference( 'ESPreventAutoTruncate', '' ); |
411 |
|
409 |
( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] ); |
412 |
( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] ); |
410 |
is( |
413 |
is( |
411 |
$query->{query}{query_string}{query}, |
414 |
$query->{query}{query_string}{query}, |
Lines 413-446
subtest 'build_query tests' => sub {
Link Here
|
413 |
"query of specific field is truncated" |
416 |
"query of specific field is truncated" |
414 |
); |
417 |
); |
415 |
|
418 |
|
416 |
( undef, $query ) = $qb->build_query_compat( undef, ['Local-number:"123456"'] ); |
419 |
( undef, $query ) = $qb->build_query_compat( undef, ['Personal-name:"donald"'] ); |
417 |
is( |
420 |
is( |
418 |
$query->{query}{query_string}{query}, |
421 |
$query->{query}{query_string}{query}, |
419 |
'(local-number:"123456")', |
422 |
'(personal-name:"donald")', |
420 |
"query of specific field including hyphen and quoted is not truncated, field name is converted to lower case" |
423 |
"query of specific field including hyphen and quoted is not truncated, field name is converted to lower case" |
421 |
); |
424 |
); |
422 |
|
425 |
|
423 |
( undef, $query ) = $qb->build_query_compat( undef, ['Local-number:123456'] ); |
426 |
( undef, $query ) = $qb->build_query_compat( undef, ['Personal-name:donald'] ); |
424 |
is( |
427 |
is( |
425 |
$query->{query}{query_string}{query}, |
428 |
$query->{query}{query_string}{query}, |
426 |
'(local-number:123456*)', |
429 |
'(personal-name:donald*)', |
427 |
"query of specific field including hyphen and not quoted is truncated, field name is converted to lower case" |
430 |
"query of specific field including hyphen and not quoted is truncated, field name is converted to lower case" |
428 |
); |
431 |
); |
429 |
|
432 |
|
430 |
( undef, $query ) = $qb->build_query_compat( undef, ['Local-number.raw:123456'] ); |
433 |
( undef, $query ) = $qb->build_query_compat( undef, ['Personal-name.raw:donald'] ); |
431 |
is( |
434 |
is( |
432 |
$query->{query}{query_string}{query}, |
435 |
$query->{query}{query_string}{query}, |
433 |
'(local-number.raw:123456*)', |
436 |
'(personal-name.raw:donald*)', |
434 |
"query of specific field including period and not quoted is truncated, field name is converted to lower case" |
437 |
"query of specific field including period and not quoted is truncated, field name is converted to lower case" |
435 |
); |
438 |
); |
436 |
|
439 |
|
437 |
( undef, $query ) = $qb->build_query_compat( undef, ['Local-number.raw:"123456"'] ); |
440 |
( undef, $query ) = $qb->build_query_compat( undef, ['Personal-name.raw:"donald"'] ); |
438 |
is( |
441 |
is( |
439 |
$query->{query}{query_string}{query}, |
442 |
$query->{query}{query_string}{query}, |
440 |
'(local-number.raw:"123456")', |
443 |
'(personal-name.raw:"donald")', |
441 |
"query of specific field including period and quoted is not truncated, field name is converted to lower case" |
444 |
"query of specific field including period and quoted is not truncated, field name is converted to lower case" |
442 |
); |
445 |
); |
443 |
|
446 |
|
|
|
447 |
# Set ESPreventAutoTruncate syspref |
448 |
t::lib::Mocks::mock_preference( 'ESPreventAutoTruncate', 'barcode' ); |
449 |
|
450 |
( undef, $query ) = $qb->build_query_compat( undef, ['barcode:123456'] ); |
451 |
is( |
452 |
$query->{query}{query_string}{query}, |
453 |
'(barcode:123456)', |
454 |
"query of specific field excluded by ESPreventAutoTruncate is not truncated" |
455 |
); |
456 |
|
457 |
( undef, $query ) = $qb->build_query_compat( undef, ['Local-number:123456'] ); |
458 |
is( |
459 |
$query->{query}{query_string}{query}, |
460 |
'(local-number:123456)', |
461 |
"query of identifier is not truncated even if QueryAutoTruncate is set" |
462 |
); |
463 |
|
464 |
( undef, $query ) = $qb->build_query_compat( undef, ['onloan:true'] ); |
465 |
is( |
466 |
$query->{query}{query_string}{query}, |
467 |
'(onloan:true)', |
468 |
"query of boolean type field is not truncated even if QueryAutoTruncate is set" |
469 |
); |
470 |
|
444 |
( undef, $query ) = $qb->build_query_compat( undef, ['J.R.R'] ); |
471 |
( undef, $query ) = $qb->build_query_compat( undef, ['J.R.R'] ); |
445 |
is( |
472 |
is( |
446 |
$query->{query}{query_string}{query}, |
473 |
$query->{query}{query_string}{query}, |
447 |
- |
|
|