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

(-)a/t/Search/Zebra/QueryBuilder.t (-1 / +39 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/env perl
2
3
use Modern::Perl;
4
5
use Test::More tests => 2;
6
use_ok('Koha::SearchEngine::Zebra::QueryBuilder');
7
8
subtest 'build_authorities_query' => sub {
9
    plan tests => 2;
10
11
    my @test_search = (
12
        ['mainmainentry'], ['and'], [''], ['contains'], ['any'], '',
13
        'HeadingAsc'
14
    );
15
    my $expected_result = {
16
        marclist     => ['mainmainentry'],
17
        and_or       => ['and'],
18
        excluding    => [''],
19
        operator     => ['contains'],
20
        value        => ['any'],
21
        authtypecode => '',
22
        orderby      => 'HeadingAsc',
23
    };
24
    my $built_search =
25
      Koha::SearchEngine::Zebra::QueryBuilder->build_authorities_query( @test_search );
26
    is_deeply(
27
        $built_search, $expected_result,
28
        "We are simply hashifying our array of refs/values, should otherwise not be altered"
29
    );
30
    $expected_result->{value} = ['"any"'];
31
    $test_search[4] = ['"any"'];
32
    $built_search =
33
      Koha::SearchEngine::Zebra::QueryBuilder->build_authorities_query( @test_search );
34
    is_deeply(
35
        $built_search, $expected_result,
36
        "The same should hold true if the search contains double quotes which will be escaped during searching by search_auth_compat subroutine"
37
    );
38
};
39

Return to bug 16976