|
Lines 98-104
subtest 'build_query_compat() SearchLimitLibrary tests' => sub {
Link Here
|
| 98 |
}; |
98 |
}; |
| 99 |
|
99 |
|
| 100 |
subtest "Handle search filters" => sub { |
100 |
subtest "Handle search filters" => sub { |
| 101 |
plan tests => 4; |
101 |
plan tests => 7; |
| 102 |
|
102 |
|
| 103 |
my $qb; |
103 |
my $qb; |
| 104 |
|
104 |
|
|
Lines 110-123
subtest "Handle search filters" => sub {
Link Here
|
| 110 |
my $filter = Koha::SearchFilter->new({ |
110 |
my $filter = Koha::SearchFilter->new({ |
| 111 |
name => "test", |
111 |
name => "test", |
| 112 |
query => q|{"operands":["cat","bat","rat"],"indexes":["kw","ti","au"],"operators":["AND","OR"]}|, |
112 |
query => q|{"operands":["cat","bat","rat"],"indexes":["kw","ti","au"],"operators":["AND","OR"]}|, |
| 113 |
limits => q|{"limits":["mc-itype,phr:BK","available"]}|, |
113 |
limits => q|{"limits":["mc-itype,phr:BK","mc-itype,phr:MU","available"]}|, |
| 114 |
})->store; |
114 |
})->store; |
| 115 |
my $filter_id = $filter->id; |
115 |
my $filter_id = $filter->id; |
| 116 |
|
116 |
|
| 117 |
my ( undef, undef, undef, undef, undef, $limit, $limit_cgi, $limit_desc ) = $qb->build_query_compat( undef, undef, undef, ["search_filter:$filter_id"] ); |
117 |
my ( undef, undef, undef, undef, undef, $limit, $limit_cgi, $limit_desc ) = $qb->build_query_compat( undef, undef, undef, ["search_filter:$filter_id"] ); |
| 118 |
|
118 |
|
| 119 |
is( $limit,q{(kw=(cat) AND ti=(bat) OR au=(rat)) and (mc-itype,phr=BK) and (( (allrecords,AlwaysMatches='') and (not-onloan-count,st-numeric >= 1) and (lost,st-numeric=0) ))},"Limit correctly formed"); |
119 |
is( $limit,q{kw=(cat) AND ti=(bat) OR au=(rat) and (mc-itype,phr=BK or mc-itype,phr=MU) and (( (allrecords,AlwaysMatches='') and (not-onloan-count,st-numeric >= 1) and (lost,st-numeric=0) ))},"Limit correctly formed"); |
| 120 |
is( $limit_cgi,"&limit=search_filter%3A$filter_id","CGI limit is not expanded"); |
120 |
is( $limit_cgi,"&limit=search_filter%3A$filter_id","CGI limit is not expanded"); |
| 121 |
is( $limit_desc,q{(kw=(cat) AND ti=(bat) OR au=(rat)) and (mc-itype,phr=BK) and (( (allrecords,AlwaysMatches='') and (not-onloan-count,st-numeric >= 1) and (lost,st-numeric=0) ))},"Limit description is correctly expanded"); |
121 |
is( $limit_desc,q{kw=(cat) AND ti=(bat) OR au=(rat) and (mc-itype,phr=BK or mc-itype,phr=MU) and (( (allrecords,AlwaysMatches='') and (not-onloan-count,st-numeric >= 1) and (lost,st-numeric=0) ))},"Limit description is correctly expanded"); |
|
|
122 |
|
| 123 |
$filter = Koha::SearchFilter->new({ |
| 124 |
name => "test", |
| 125 |
query => q|{"operands":["su:biography"],"indexes":[],"operators":[]}|, |
| 126 |
limits => q|{"limits":[]}|, |
| 127 |
})->store; |
| 128 |
$filter_id = $filter->id; |
| 129 |
|
| 130 |
( undef, undef, undef, undef, undef, $limit, $limit_cgi, $limit_desc ) = $qb->build_query_compat( undef, undef, undef, ["search_filter:$filter_id"] ); |
| 131 |
|
| 132 |
is( $limit,q{(su=biography)},"Limit correctly formed for ccl type query"); |
| 133 |
is( $limit_cgi,"&limit=search_filter%3A$filter_id","CGI limit is not expanded"); |
| 134 |
is( $limit_desc,q{(su=biography)},"Limit description is correctly handled for ccl type query"); |
| 122 |
|
135 |
|
| 123 |
}; |
136 |
}; |
| 124 |
- |
|
|