Merge remote-tracking branch 'origin/new/bug_7768'
[koha.git] / test / search.pl
blob4362791b74c32779117cdad698ce78a1aae518b5
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 $stopwords_removed,
41 $query_type )
42 = buildQuery( $_->{operators}, $_->{operands}, $_->{indexes}, $_->{limits}, $_->{sort_by}, 0, $_->{lang} );
44 die $error if $error;
46 $expected = $_->{query};
47 push @mismatch, "Query: $query (not: $expected)" unless $query eq $expected;
49 $expected = $_->{simple_query};
50 push @mismatch, "Simple Query: $simple_query (not: $expected)" unless $simple_query eq $expected;
52 $expected = $_->{query_cgi};
53 push @mismatch, "Query CGI: $query_cgi (not: $expected)" unless $query_cgi eq $expected;
55 $expected = $_->{query_desc};
56 push @mismatch, "Query desc: $query_desc (not: $expected)" unless $query_desc eq $expected;
58 $expected = $_->{limit};
59 push @mismatch, "Limit: $limit (not: $expected)" unless $limit eq $expected;
61 $expected = $_->{limit_cgi};
62 push @mismatch, "Limit CGI: $limit_cgi (not: $expected)" unless $limit_cgi eq $expected;
64 $expected = $_->{limit_desc};
65 push @mismatch, "Limit desc: $limit_desc (not: $expected)" unless $limit_desc eq $expected;
67 $expected = $_->{stopwords_removed};
68 push @mismatch, "Stopwords removed: $stopwords_removed (not: $expected)" unless $stopwords_removed eq $expected;
70 $expected = $_->{query_type};
71 push @mismatch, "Query Type: $query_type (not: $expected)" unless $query_type eq $expected;
73 die map "$_\n", @mismatch if @mismatch;