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

(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-2 / +38 lines)
Lines 21-27 use C4::Context; Link Here
21
use Test::Exception;
21
use Test::Exception;
22
use t::lib::Mocks;
22
use t::lib::Mocks;
23
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
24
use Test::More tests => 6;
24
use Test::More tests => 7;
25
25
26
use Koha::Database;
26
use Koha::Database;
27
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
27
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
Lines 485-488 subtest "_sort_field() tests" => sub { Link Here
485
    );
485
    );
486
};
486
};
487
487
488
subtest 'build_query_compat() limit tests' => sub {
489
    plan tests => 6;
490
491
    my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new({ 'index' => 'biblios' }),
492
    my @operators = ();
493
    my @operands = ();
494
    my @indexes = ();
495
    my @orig_limits = ('itype:BK');
496
    my @sort_by = ();
497
    my $scan = undef;
498
    my $lang = undef;
499
    my @params = ( \@operators, \@operands, \@indexes, \@orig_limits, \@sort_by, $scan, $lang );
500
    my (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
501
    is( $limit, ( 'itype:BK' ), "We pass through a known type");
502
503
    @orig_limits = ('itype:BK2');
504
    (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
505
    is( $limit, ('itype:BK2' ), "We pass through and quote a known type requested as phrase");
506
507
    @orig_limits = ('ti:monkey');
508
    (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
509
    is( $limit, ('title:monkey' ), "We convert and pass through a known type");
510
511
    @orig_limits = ('ti,phr:monkey');
512
    (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
513
    is( $limit, ('title:"monkey"' ), "We convert, quote, and pass through a known type requested as phrase");
514
515
    @orig_limits = ('monkey:banana');
516
    (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
517
    is( $limit, ('monkey:banana' ), "We pass through an unknown type");
518
519
    @orig_limits = ('ti,phr:monkey');
520
    (undef, $query, undef, undef, undef, $limit) = $builder->build_query_compat( @params );
521
    is( $limit, ('title:"monkey"' ), "We quote and pass through an unknown type requested as phrase");
522
523
};
524
488
$schema->storage->txn_rollback;
525
$schema->storage->txn_rollback;
489
- 

Return to bug 18163