Lines 84-91
use t::lib::Mocks;
Link Here
|
84 |
use t::lib::TestBuilder; |
84 |
use t::lib::TestBuilder; |
85 |
use Koha::Database; |
85 |
use Koha::Database; |
86 |
|
86 |
|
87 |
my $t = Test::Mojo->new; |
|
|
88 |
|
89 |
my $schema = Koha::Database->new()->schema(); |
87 |
my $schema = Koha::Database->new()->schema(); |
90 |
my $builder = t::lib::TestBuilder->new; |
88 |
my $builder = t::lib::TestBuilder->new; |
91 |
|
89 |
|
Lines 119-124
subtest 'objects.search helper' => sub {
Link Here
|
119 |
} |
117 |
} |
120 |
}); |
118 |
}); |
121 |
|
119 |
|
|
|
120 |
my $t = Test::Mojo->new; |
122 |
$t->get_ok('/cities?name=manuel&_per_page=1&_page=1') |
121 |
$t->get_ok('/cities?name=manuel&_per_page=1&_page=1') |
123 |
->status_is(200) |
122 |
->status_is(200) |
124 |
->header_like( 'Link' => qr/<http:\/\/.*[\?&]_page=2.*>; rel="next",/ ) |
123 |
->header_like( 'Link' => qr/<http:\/\/.*[\?&]_page=2.*>; rel="next",/ ) |
Lines 219-224
subtest 'objects.search helper, sorting on mapped column' => sub {
Link Here
|
219 |
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'A', city_country => 'Argentina' } }); |
218 |
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'A', city_country => 'Argentina' } }); |
220 |
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'B', city_country => 'Argentina' } }); |
219 |
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'B', city_country => 'Argentina' } }); |
221 |
|
220 |
|
|
|
221 |
my $t = Test::Mojo->new; |
222 |
$t->get_ok('/cities?_order_by=%2Bname&_order_by=+country') |
222 |
$t->get_ok('/cities?_order_by=%2Bname&_order_by=+country') |
223 |
->status_is(200) |
223 |
->status_is(200) |
224 |
->json_has('/0') |
224 |
->json_has('/0') |
Lines 249-254
subtest 'objects.search helper, encoding' => sub {
Link Here
|
249 |
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'A', city_country => 'Argentina' } }); |
249 |
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'A', city_country => 'Argentina' } }); |
250 |
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'B', city_country => '❤Argentina❤' } }); |
250 |
$builder->build_object({ class => 'Koha::Cities', value => { city_name => 'B', city_country => '❤Argentina❤' } }); |
251 |
|
251 |
|
|
|
252 |
my $t = Test::Mojo->new; |
252 |
$t->get_ok('/cities?q={"country": "❤Argentina❤"}') |
253 |
$t->get_ok('/cities?q={"country": "❤Argentina❤"}') |
253 |
->status_is(200) |
254 |
->status_is(200) |
254 |
->json_has('/0') |
255 |
->json_has('/0') |
Lines 266-271
subtest 'objects.search helper, embed' => sub {
Link Here
|
266 |
|
267 |
|
267 |
my $order = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); |
268 |
my $order = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); |
268 |
|
269 |
|
|
|
270 |
my $t = Test::Mojo->new; |
269 |
$t->get_ok('/orders?order_id=' . $order->ordernumber) |
271 |
$t->get_ok('/orders?order_id=' . $order->ordernumber) |
270 |
->json_is('/0',$order->to_api({ embed => ( { fund => {} } ) })); |
272 |
->json_is('/0',$order->to_api({ embed => ( { fund => {} } ) })); |
271 |
|
273 |
|
Lines 290-295
subtest 'objects.search helper, with path parameters and _match' => sub {
Link Here
|
290 |
} |
292 |
} |
291 |
); |
293 |
); |
292 |
|
294 |
|
|
|
295 |
my $t = Test::Mojo->new; |
293 |
$t->get_ok('/patrons/1/holds?_match=exact') |
296 |
$t->get_ok('/patrons/1/holds?_match=exact') |
294 |
->json_is('/count' => 0, 'there should be no holds for borrower 1 with _match=exact'); |
297 |
->json_is('/count' => 0, 'there should be no holds for borrower 1 with _match=exact'); |
295 |
|
298 |
|
Lines 319-324
subtest 'object.search helper with query parameter' => sub {
Link Here
|
319 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
322 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
320 |
my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); |
323 |
my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); |
321 |
|
324 |
|
|
|
325 |
my $t = Test::Mojo->new; |
322 |
$t->get_ok('/biblios' => json => {"suggestions.suggester.patron_id" => $patron1->borrowernumber }) |
326 |
$t->get_ok('/biblios' => json => {"suggestions.suggester.patron_id" => $patron1->borrowernumber }) |
323 |
->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); |
327 |
->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); |
324 |
|
328 |
|
Lines 342-347
subtest 'object.search helper with q parameter' => sub {
Link Here
|
342 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
346 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
343 |
my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); |
347 |
my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); |
344 |
|
348 |
|
|
|
349 |
my $t = Test::Mojo->new; |
345 |
$t->get_ok('/biblios?q={"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}') |
350 |
$t->get_ok('/biblios?q={"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}') |
346 |
->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); |
351 |
->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); |
347 |
|
352 |
|
Lines 365-370
subtest 'object.search helper with x-koha-query header' => sub {
Link Here
|
365 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
370 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
366 |
my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); |
371 |
my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); |
367 |
|
372 |
|
|
|
373 |
my $t = Test::Mojo->new; |
368 |
$t->get_ok('/biblios' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}'}) |
374 |
$t->get_ok('/biblios' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}'}) |
369 |
->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); |
375 |
->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); |
370 |
|
376 |
|
Lines 388-393
subtest 'object.search helper with all query methods' => sub {
Link Here
|
388 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
394 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
389 |
my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); |
395 |
my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); |
390 |
|
396 |
|
|
|
397 |
my $t = Test::Mojo->new; |
391 |
$t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron1->firstname.'"}' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron1->cardnumber}) |
398 |
$t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron1->firstname.'"}' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron1->cardnumber}) |
392 |
->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); |
399 |
->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); |
393 |
|
400 |
|
Lines 410-415
subtest 'object.search helper order by embedded columns' => sub {
Link Here
|
410 |
my $suggestion1 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron1->borrowernumber, biblionumber => $biblio1->biblionumber} } ); |
417 |
my $suggestion1 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron1->borrowernumber, biblionumber => $biblio1->biblionumber} } ); |
411 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
418 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
412 |
|
419 |
|
|
|
420 |
my $t = Test::Mojo->new; |
413 |
$t->get_ok('/biblios?_order_by=-suggestions.suggester.firstname' => json => [{"me.biblio_id" => $biblio1->biblionumber}, {"me.biblio_id" => $biblio2->biblionumber}]) |
421 |
$t->get_ok('/biblios?_order_by=-suggestions.suggester.firstname' => json => [{"me.biblio_id" => $biblio1->biblionumber}, {"me.biblio_id" => $biblio2->biblionumber}]) |
414 |
->json_is('/biblios/0/biblio_id' => $biblio2->biblionumber, 'Biblio 2 should be first') |
422 |
->json_is('/biblios/0/biblio_id' => $biblio2->biblionumber, 'Biblio 2 should be first') |
415 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
423 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
416 |
- |
|
|