3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test
::More tests
=> 3;
25 qw
/_build_initial_query/);
28 subtest
"_build_initial_query tests" => sub {
32 my ($query,$query_cgi,$query_desc,$previous_operand);
33 # all params have values
36 query_cgi
=> "query_cgi",
37 query_desc
=> "query_desc",
38 operator
=> "operator",
39 parsed_operand
=> "parsed_operand",
40 original_operand
=> "original_operand",
42 index_plus
=> "index_plus",
43 indexes_set
=> "indexes_set",
44 previous_operand
=> "previous_operand"
47 ($query,$query_cgi,$query_desc,$previous_operand) =
48 C4
::Search
::_build_initial_query
($params);
49 is
( $query, "query operator parsed_operand",
50 "\$query built correctly");
51 is
( $query_cgi, "query_cgi&op=%20operator%20&idx=index&q=original_operand",
52 "\$query_cgi built correctly");
53 is
( $query_desc, "query_desc operator index_plus original_operand",
54 "\$query_desc build correctly");
55 is
( $previous_operand, "previous_operand",
56 "\$query build correctly");
61 query_cgi
=> "query_cgi",
62 query_desc
=> "query_desc",
64 parsed_operand
=> "parsed_operand",
65 original_operand
=> "original_operand",
67 index_plus
=> "index_plus",
68 indexes_set
=> "indexes_set",
69 previous_operand
=> "previous_operand"
72 ($query,$query_cgi,$query_desc,$previous_operand) =
73 C4
::Search
::_build_initial_query
($params);
74 is
( $query, "query and parsed_operand",
75 "\$query built correctly (no operator)");
76 is
( $query_cgi, "query_cgi&op=%20and%20&idx=index&q=original_operand",
77 "\$query_cgi built correctly (no operator)");
78 is
( $query_desc, "query_desc and index_plus original_operand",
79 "\$query_desc build correctly (no operator)");
80 is
( $previous_operand, "previous_operand",
81 "\$query build correctly (no operator)");
86 query_cgi
=> "query_cgi",
87 query_desc
=> "query_desc",
88 operator
=> "operator",
89 parsed_operand
=> "parsed_operand",
90 original_operand
=> "original_operand",
92 index_plus
=> "index_plus",
93 indexes_set
=> "indexes_set",
94 previous_operand
=> undef
97 ($query,$query_cgi,$query_desc,$previous_operand) =
98 C4
::Search
::_build_initial_query
($params);
99 is
( $query, "queryparsed_operand",
100 "\$query built correctly (no previous operand)");
101 is
( $query_cgi, "query_cgi&idx=index&q=original_operand",
102 "\$query_cgi built correctly (no previous operand)");
103 is
( $query_desc, "query_descindex_plus original_operand",
104 "\$query_desc build correctly (no previous operand)");
105 is
( $previous_operand, 1,
106 "\$query build correctly (no previous operand)");
111 query_cgi
=> "query_cgi",
112 query_desc
=> "query_desc",
113 operator
=> "operator",
114 parsed_operand
=> "parsed_operand",
115 original_operand
=> "original_operand",
117 index_plus
=> "index_plus",
118 indexes_set
=> "indexes_set",
119 previous_operand
=> "previous_operand"
122 ($query,$query_cgi,$query_desc,$previous_operand) =
123 C4
::Search
::_build_initial_query
($params);
124 is
( $query, "query operator parsed_operand",
125 "\$query built correctly (no index passed)");
126 is
( $query_cgi, "query_cgi&op=%20operator%20&q=original_operand",
127 "\$query_cgi built correctly (no index passed)");
128 is
( $query_desc, "query_desc operator index_plus original_operand",
129 "\$query_desc build correctly (no index passed)");
130 is
( $previous_operand, "previous_operand",
131 "\$query build correctly (no index passed)");
133 # no index_plus passed
136 query_cgi
=> "query_cgi",
137 query_desc
=> "query_desc",
138 operator
=> "operator",
139 parsed_operand
=> "parsed_operand",
140 original_operand
=> "original_operand",
143 indexes_set
=> "indexes_set",
144 previous_operand
=> "previous_operand"
147 ($query,$query_cgi,$query_desc,$previous_operand) =
148 C4
::Search
::_build_initial_query
($params);
149 is
( $query, "query operator parsed_operand",
150 "\$query built correctly (no index_plus passed)");
151 is
( $query_cgi, "query_cgi&op=%20operator%20&idx=index&q=original_operand",
152 "\$query_cgi built correctly (no index_plus passed)");
153 is
( $query_desc, "query_desc operator original_operand",
154 "\$query_desc build correctly (no index_plus passed)");
155 is
( $previous_operand, "previous_operand",
156 "\$query build correctly (no index_plus passed)");