Lines 102-119
subtest 'build_query tests' => sub {
Link Here
|
102 |
ok( !defined $query->{aggregations}{holdingbranch}, |
102 |
ok( !defined $query->{aggregations}{holdingbranch}, |
103 |
'holdingbranch not added to facets if DisplayLibraryFacets=home' ); |
103 |
'holdingbranch not added to facets if DisplayLibraryFacets=home' ); |
104 |
|
104 |
|
105 |
t::lib::Mocks::mock_preference('QueryAutoTruncate',''); |
105 |
t::lib::Mocks::mock_preference( 'QueryAutoTruncate', '' ); |
106 |
( undef, $query ) = $builder->build_query_compat( undef, ['donald duck'] ); |
|
|
107 |
is( $query->{query}{query_string}{query}, "(donald duck)", "query not altered if QueryAutoTruncate disabled" ); |
108 |
|
106 |
|
109 |
t::lib::Mocks::mock_preference('QueryAutoTruncate','1'); |
|
|
110 |
( undef, $query ) = $builder->build_query_compat( undef, ['donald duck'] ); |
107 |
( undef, $query ) = $builder->build_query_compat( undef, ['donald duck'] ); |
111 |
is( $query->{query}{query_string}{query}, "(donald* duck*)", "simple query is auto truncated when QueryAutoTruncate enabled" ); |
108 |
is( |
112 |
( undef, $query ) = $builder->build_query_compat( undef, ['donald or duck and mickey not mouse'] ); |
109 |
$query->{query}{query_string}{query}, |
113 |
is( $query->{query}{query_string}{query}, "(donald* or duck* and mickey* not mouse*)", "reserved words are not affected by QueryAutoTruncate" ); #Ensure reserved words are not truncated |
110 |
"(donald duck)", |
114 |
( undef, $query ) = $builder->build_query_compat( undef, ['donald* duck*'] ); |
111 |
"query not altered if QueryAutoTruncate disabled" |
115 |
is( $query->{query}{query_string}{query}, "(donald* duck*)", "query with '*' is unaltered when QueryAutoTruncate is enabled" ); |
112 |
); |
116 |
|
113 |
|
|
|
114 |
t::lib::Mocks::mock_preference( 'QueryAutoTruncate', '1' ); |
117 |
|
115 |
|
|
|
116 |
( undef, $query ) = $builder->build_query_compat( undef, ['donald duck'] ); |
117 |
is( |
118 |
$query->{query}{query_string}{query}, |
119 |
"(donald* duck*)", |
120 |
"simple query is auto truncated when QueryAutoTruncate enabled" |
121 |
); |
122 |
|
123 |
# Ensure reserved words are not truncated |
124 |
( undef, $query ) = $builder->build_query_compat( undef, |
125 |
['donald or duck and mickey not mouse'] ); |
126 |
is( |
127 |
$query->{query}{query_string}{query}, |
128 |
"(donald* or duck* and mickey* not mouse*)", |
129 |
"reserved words are not affected by QueryAutoTruncate" |
130 |
); |
131 |
|
132 |
( undef, $query ) = $builder->build_query_compat( undef, ['donald* duck*'] ); |
133 |
is( |
134 |
$query->{query}{query_string}{query}, |
135 |
"(donald* duck*)", |
136 |
"query with '*' is unaltered when QueryAutoTruncate is enabled" |
137 |
); |
118 |
}; |
138 |
}; |
119 |
|
139 |
|
120 |
- |
|
|