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

(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-2 / +41 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 2;
20
use Test::More tests => 3;
21
use Test::Exception;
21
use Test::Exception;
22
22
23
use Koha::Database;
23
use Koha::Database;
Lines 77-79 subtest 'build query from form subtests' => sub { Link Here
77
77
78
78
79
};
79
};
80
- 
80
81
subtest 'build_query_compat() limit tests' => sub {
82
    plan tests => 6;
83
84
    my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new({ 'index' => 'biblios' }),
85
    my @operators = ();
86
    my @operands = ();
87
    my @indexes = ();
88
    my @orig_limits = ('itype:BK');
89
    my @sort_by = ();
90
    my $scan = undef;
91
    my $lang = undef;
92
    my @params = ( \@operators, \@operands, \@indexes, \@orig_limits, \@sort_by, $scan, $lang );
93
    my (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
94
    is( $limit, ( 'itype:BK' ), "We pass through a known type");
95
96
    @orig_limits = ('itype:BK2');
97
    (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
98
    is( $limit, ('itype:BK2' ), "We pass through and quote a known type requested as phrase");
99
100
    @orig_limits = ('ti:monkey');
101
    (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
102
    is( $limit, ('title:monkey' ), "We convert and pass through a known type");
103
104
    @orig_limits = ('ti,phr:monkey');
105
    (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
106
    is( $limit, ('title:"monkey"' ), "We convert, quote, and pass through a known type requested as phrase");
107
108
    @orig_limits = ('monkey:banana');
109
    (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
110
    is( $limit, ('monkey:banana' ), "We pass through an unknown type");
111
112
    @orig_limits = ('ti,phr:monkey');
113
    (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
114
    is( $limit, ('title:"monkey"' ), "We quote and pass through an unknown type requested as phrase");
115
116
};
117
118
119
    

Return to bug 18163