View | Details | Raw Unified | Return to bug 17170
Collapse All | Expand All

(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-1 / +27 lines)
Lines 22-33 use Test::Exception; Link Here
22
use Test::Warn;
22
use Test::Warn;
23
use t::lib::Mocks;
23
use t::lib::Mocks;
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
25
use Test::More tests => 7;
25
use Test::More tests => 8;
26
26
27
use List::Util qw( all );
27
use List::Util qw( all );
28
28
29
use Koha::Database;
29
use Koha::Database;
30
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
30
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
31
use Koha::SearchFilters;
31
32
32
my $schema = Koha::Database->new->schema;
33
my $schema = Koha::Database->new->schema;
33
$schema->storage->txn_begin;
34
$schema->storage->txn_begin;
Lines 780-785 subtest 'build_query_compat() SearchLimitLibrary tests' => sub { Link Here
780
781
781
};
782
};
782
783
784
subtest "Handle search filters" => sub {
785
    plan tests => 4;
786
787
    my $qb;
788
789
    ok(
790
        $qb = Koha::SearchEngine::Elasticsearch::QueryBuilder->new({ 'index' => 'biblios' }),
791
        'Creating new query builder object for biblios'
792
    );
793
794
    my $filter = Koha::SearchFilter->new({
795
        name => "test",
796
        query => q|{"operands":["cat","bat","rat"],"indexes":["kw","ti","au"],"operators":["AND","OR"]}|,
797
        limits => q|{"limits":["mc-itype,phr:BK","available"]}|,
798
    })->store;
799
    my $filter_id = $filter->id;
800
801
    my ( undef, undef, undef, undef, undef, $limit, $limit_cgi, $limit_desc ) = $qb->build_query_compat( undef, undef, undef, ["search_filter:$filter_id"] );
802
803
    is( $limit,q{(itype:("BK")) AND (onloan:false) AND (((cat) AND title:(bat) OR author:(rat)))},"Limit correctly formed");
804
    is( $limit_cgi,"&limit=search_filter%3A$filter_id","CGI limit is not expanded");
805
    is( $limit_desc,q{(itype:("BK")) AND (onloan:false) AND (((cat) AND title:(bat) OR author:(rat)))},"Limit description is correctly expanded");
806
807
};
808
783
subtest "_convert_sort_fields() tests" => sub {
809
subtest "_convert_sort_fields() tests" => sub {
784
    plan tests => 3;
810
    plan tests => 3;
785
811
(-)a/t/db_dependent/Koha/SearchEngine/Zebra/QueryBuilder.t (-2 / +26 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 1;
20
use Test::More tests => 2;
21
use t::lib::Mocks;
21
use t::lib::Mocks;
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
use Test::MockModule;
23
use Test::MockModule;
Lines 96-98 subtest 'build_query_compat() SearchLimitLibrary tests' => sub { Link Here
96
    is( $limit_cgi, "&limit=multibranchlimit%3A$groupid", "Limit cgi does not get expanded");
96
    is( $limit_cgi, "&limit=multibranchlimit%3A$groupid", "Limit cgi does not get expanded");
97
97
98
};
98
};
99
- 
99
100
subtest "Handle search filters" => sub {
101
    plan tests => 4;
102
103
    my $qb;
104
105
    ok(
106
        $qb = Koha::SearchEngine::Zebra::QueryBuilder->new({ 'index' => 'biblios' }),
107
        'Creating new query builder object for biblios'
108
    );
109
110
    my $filter = Koha::SearchFilter->new({
111
        name => "test",
112
        query => q|{"operands":["cat","bat","rat"],"indexes":["kw","ti","au"],"operators":["AND","OR"]}|,
113
        limits => q|{"limits":["mc-itype,phr:BK","available"]}|,
114
    })->store;
115
    my $filter_id = $filter->id;
116
117
    my ( undef, undef, undef, undef, undef, $limit, $limit_cgi, $limit_desc ) = $qb->build_query_compat( undef, undef, undef, ["search_filter:$filter_id"] );
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");
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");
122
123
};

Return to bug 17170