Bug 6046: suggestedby list on she filter was not created properly
[wip/koha-chris_n.git] / test / search.pl
1 #!/usr/bin/perl -w
2
3 use C4::Search;
4
5 my @SEARCH = (
6     { operators => [
7           'and',
8           'and'
9       ],
10       operands => [
11           'shakespeare, "(william)"',
12           'dream'
13       ],
14       indexes => [
15           'au,wrdl',
16           'ti',
17           'kw'
18       ],
19       limits => [
20           'yr,st-numeric=2000-'
21       ],
22       sort_by => [
23           'relevance'
24       ],
25       lang => 'en',
26     },
27 );
28
29
30 foreach ( @SEARCH ) {
31     my ($expected, @mismatch);
32     my( $error,
33         $query,
34         $simple_query,
35         $query_cgi,
36         $query_desc,
37         $limit,
38         $limit_cgi,
39         $limit_desc,
40         $stopwords_removed,
41         $query_type )
42       = buildQuery( $_->{operators}, $_->{operands}, $_->{indexes}, $_->{limits}, $_->{sort_by}, 0,  $_->{lang} );
43
44     die $error if $error;
45
46     $expected = $_->{query};
47     push @mismatch, "Query: $query (not: $expected)" unless $query eq $expected;
48
49     $expected = $_->{simple_query};
50     push @mismatch, "Simple Query: $simple_query (not: $expected)" unless $simple_query eq $expected;
51
52     $expected = $_->{query_cgi};
53     push @mismatch, "Query CGI: $query_cgi (not: $expected)" unless $query_cgi eq $expected;
54
55     $expected = $_->{query_desc};
56     push @mismatch, "Query desc: $query_desc (not: $expected)" unless $query_desc eq $expected;
57
58     $expected = $_->{limit};
59     push @mismatch, "Limit: $limit (not: $expected)" unless $limit eq $expected;
60
61     $expected = $_->{limit_cgi};
62     push @mismatch, "Limit CGI: $limit_cgi (not: $expected)" unless $limit_cgi eq $expected;
63
64     $expected = $_->{limit_desc};
65     push @mismatch, "Limit desc: $limit_desc (not: $expected)" unless $limit_desc eq $expected;
66
67     $expected = $_->{stopwords_removed};
68     push @mismatch, "Stopwords removed: $stopwords_removed (not: $expected)" unless $stopwords_removed eq $expected;
69
70     $expected = $_->{query_type};
71     push @mismatch, "Query Type: $query_type (not: $expected)" unless $query_type eq $expected;
72
73     die map "$_\n", @mismatch if @mismatch;
74 }