|
Lines 22-28
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 |
|
|
Lines 101-110
$se->mock( 'get_elasticsearch_mappings', sub {
Link Here
|
| 101 |
return $all_mappings{$self->index}; |
101 |
return $all_mappings{$self->index}; |
| 102 |
}); |
102 |
}); |
| 103 |
|
103 |
|
|
|
104 |
subtest 'build_authorities_query_compat() no query truncate tests' => sub { |
| 105 |
|
| 106 |
plan tests => 9; |
| 107 |
|
| 108 |
t::lib::Mocks::mock_preference( 'QueryAutoTruncate', '' ); |
| 109 |
|
| 110 |
my $qb; |
| 111 |
|
| 112 |
ok( |
| 113 |
$qb = Koha::SearchEngine::Elasticsearch::QueryBuilder->new({ 'index' => 'authorities' }), |
| 114 |
'Creating new query builder object for authorities' |
| 115 |
); |
| 116 |
|
| 117 |
my $koha_to_index_name = $Koha::SearchEngine::Elasticsearch::QueryBuilder::koha_to_index_name; |
| 118 |
my $search_term = 'a'; |
| 119 |
foreach my $koha_name ( keys %{ $koha_to_index_name } ) { |
| 120 |
my $query = $qb->build_authorities_query_compat( [ $koha_name ], undef, undef, ['contains'], [$search_term], 'AUTH_TYPE', 'asc' ); |
| 121 |
is( $query->{query}->{bool}->{must}[0]->{query_string}->{query}, 'a'); |
| 122 |
} |
| 123 |
}; |
| 124 |
|
| 104 |
subtest 'build_authorities_query_compat() tests' => sub { |
125 |
subtest 'build_authorities_query_compat() tests' => sub { |
| 105 |
|
126 |
|
| 106 |
plan tests => 65; |
127 |
plan tests => 65; |
| 107 |
|
128 |
|
|
|
129 |
t::lib::Mocks::mock_preference( 'QueryAutoTruncate', 1 ); |
| 130 |
|
| 108 |
my $qb; |
131 |
my $qb; |
| 109 |
|
132 |
|
| 110 |
ok( |
133 |
ok( |
| 111 |
- |
|
|