Bugzilla – Attachment 131821 Details for
Bug 30165
Several q parameters break the filters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30165: Regression tests
Bug-30165-Regression-tests.patch (text/plain), 3.73 KB, created by
Jonathan Druart
on 2022-03-17 08:35:00 UTC
(
hide
)
Description:
Bug 30165: Regression tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-03-17 08:35:00 UTC
Size:
3.73 KB
patch
obsolete
>From b8705ab67cad8d4a34200a61259d094213ca0347 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 25 Feb 2022 08:45:26 -0300 >Subject: [PATCH] Bug 30165: Regression tests > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/api/v1/query.t | 104 ++++++++++++++++++++++++++++++++++ > 1 file changed, 104 insertions(+) > create mode 100755 t/db_dependent/api/v1/query.t > >diff --git a/t/db_dependent/api/v1/query.t b/t/db_dependent/api/v1/query.t >new file mode 100755 >index 00000000000..e986ab708e1 >--- /dev/null >+++ b/t/db_dependent/api/v1/query.t >@@ -0,0 +1,104 @@ >+#!/usr/bin/env perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+use Test::Mojo; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+use Koha::Cities; >+use Koha::Database; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+my $t = Test::Mojo->new('Koha::REST::V1'); >+t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ >+subtest 'q handling tests' => sub { >+ >+ plan tests => 15; >+ >+ $schema->storage->txn_begin; >+ >+ my $librarian = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 2**2 } # catalogue flag = 2 >+ } >+ ); >+ my $password = 'thePassword123'; >+ $librarian->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $librarian->userid; >+ >+ # delete all cities >+ Koha::Cities->new->delete; >+ >+ # No cities, so empty array should be returned >+ $t->get_ok("//$userid:$password@/api/v1/cities")->status_is(200) >+ ->json_is( [] ); >+ >+ my $names = [ 'AA', 'BA', 'BA', 'CA', 'DA', 'EB', 'FB', 'GB', 'HB', 'IB', ]; >+ >+ # Add 10 cities >+ foreach my $i ( 0 .. 9 ) { >+ $builder->build_object( >+ { class => 'Koha::Cities', value => { city_name => $names->[$i] } } >+ ); >+ } >+ >+ t::lib::Mocks::mock_preference( 'RESTdefaultPageSize', 20 ); >+ >+ my $q_ends_with_a = 'q={"name":{"-like":"%A"}}'; >+ >+ my $cities = >+ $t->get_ok( >+ "//$userid:$password@/api/v1/cities?$q_ends_with_a") >+ ->status_is(200)->tx->res->json; >+ >+ is( scalar @{$cities}, 5, '5 cities retrieved' ); >+ >+ my $q_starts_with_a = 'q={"name":{"-like":"A%"}}'; >+ >+ $cities = >+ $t->get_ok( >+ "//$userid:$password@/api/v1/cities?$q_ends_with_a&$q_starts_with_a") >+ ->status_is(200)->tx->res->json; >+ >+ is( scalar @{$cities}, 1, '1 city retrieved' ); >+ >+ my $q_empty_list = "q=[]"; >+ >+ $cities = >+ $t->get_ok( >+ "//$userid:$password@/api/v1/cities?$q_ends_with_a&$q_starts_with_a&$q_empty_list") >+ ->status_is(200)->tx->res->json; >+ >+ is( scalar @{$cities}, 1, 'empty list as trailing query, 1 city retrieved' ); >+ >+ $cities = >+ $t->get_ok( >+ "//$userid:$password@/api/v1/cities?$q_empty_list&$q_ends_with_a&$q_starts_with_a") >+ ->status_is(200)->tx->res->json; >+ >+ is( scalar @{$cities}, 1, 'empty list as first query, 1 city retrieved' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30165
:
131111
|
131706
|
131707
|
131759
|
131760
|
131761
|
131803
|
131804
|
131805
| 131821 |
131822
|
131823
|
132138
|
132139