Bug 19469: Clean up template whitespace
[koha.git] / test / search.pl
blob5d4f6e8d7655e37a05ab5b1003a59ed5391379eb
1 #!/usr/bin/perl -w
3 use C4::Search;
5 my @SEARCH = (
6 { operators => [
7 'and',
8 'and'
9 ],
10 operands => [
11 'shakespeare, "(william)"',
12 'dream'
14 indexes => [
15 'au,wrdl',
16 'ti',
17 'kw'
19 limits => [
20 'yr,st-numeric=2000-'
22 sort_by => [
23 'relevance'
25 lang => 'en',
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 $query_type )
41 = buildQuery( $_->{operators}, $_->{operands}, $_->{indexes}, $_->{limits}, $_->{sort_by}, 0, $_->{lang} );
43 die $error if $error;
45 $expected = $_->{query};
46 push @mismatch, "Query: $query (not: $expected)" unless $query eq $expected;
48 $expected = $_->{simple_query};
49 push @mismatch, "Simple Query: $simple_query (not: $expected)" unless $simple_query eq $expected;
51 $expected = $_->{query_cgi};
52 push @mismatch, "Query CGI: $query_cgi (not: $expected)" unless $query_cgi eq $expected;
54 $expected = $_->{query_desc};
55 push @mismatch, "Query desc: $query_desc (not: $expected)" unless $query_desc eq $expected;
57 $expected = $_->{limit};
58 push @mismatch, "Limit: $limit (not: $expected)" unless $limit eq $expected;
60 $expected = $_->{limit_cgi};
61 push @mismatch, "Limit CGI: $limit_cgi (not: $expected)" unless $limit_cgi eq $expected;
63 $expected = $_->{limit_desc};
64 push @mismatch, "Limit desc: $limit_desc (not: $expected)" unless $limit_desc eq $expected;
66 $expected = $_->{query_type};
67 push @mismatch, "Query Type: $query_type (not: $expected)" unless $query_type eq $expected;
69 die map "$_\n", @mismatch if @mismatch;