Lines 128-167
subtest 'dbic_merge_sorting() tests' => sub {
Link Here
|
128 |
] |
128 |
] |
129 |
); |
129 |
); |
130 |
}; |
130 |
}; |
131 |
|
|
|
132 |
subtest '_build_query_params_from_api' => sub { |
133 |
|
134 |
plan tests => 16; |
135 |
|
136 |
my $t = Test::Mojo->new; |
137 |
|
138 |
# _match => contains |
139 |
$t->get_ok('/build_query?_match=contains&title=Ender&author=Orson') |
140 |
->status_is(200) |
141 |
->json_is( '/query' => |
142 |
{ author => { like => '%Orson%' }, title => { like => '%Ender%' } } ); |
143 |
|
144 |
# _match => starts_with |
145 |
$t->get_ok('/build_query?_match=starts_with&title=Ender&author=Orson') |
146 |
->status_is(200) |
147 |
->json_is( '/query' => |
148 |
{ author => { like => 'Orson%' }, title => { like => 'Ender%' } } ); |
149 |
|
150 |
# _match => ends_with |
151 |
$t->get_ok('/build_query?_match=ends_with&title=Ender&author=Orson') |
152 |
->status_is(200) |
153 |
->json_is( '/query' => |
154 |
{ author => { like => '%Orson' }, title => { like => '%Ender' } } ); |
155 |
|
156 |
# _match => exact |
157 |
$t->get_ok('/build_query?_match=exact&title=Ender&author=Orson') |
158 |
->status_is(200) |
159 |
->json_is( '/query' => { author => 'Orson', title => 'Ender' } ); |
160 |
|
161 |
# _match => blah |
162 |
$t->get_ok('/build_query?_match=blah&title=Ender&author=Orson') |
163 |
->status_is(400) |
164 |
->json_is( '/exception_msg' => 'Invalid value for _match param (blah)' ) |
165 |
->json_is( '/exception_type' => 'Koha::Exceptions::WrongParameter' ); |
166 |
|
167 |
}; |
168 |
- |