Bugzilla – Attachment 103142 Details for
Bug 24487
build_query_params helper builds path parameter with matching criteria
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[19.11.x] Bug 24487: Regresion test
Bug-24487-Regresion-test.patch (text/plain), 2.70 KB, created by
Kyle M Hall (khall)
on 2020-04-17 10:54:45 UTC
(
hide
)
Description:
[19.11.x] Bug 24487: Regresion test
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-04-17 10:54:45 UTC
Size:
2.70 KB
patch
obsolete
>From e5e0cd0d2dc607983ef27664359d30e42f375119 Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Wed, 22 Jan 2020 20:44:04 -0300 >Subject: [PATCH] Bug 24487: Regresion test > >This patch introduces a regresion test where a path parameter is combined with 'contains' match criteria > >To test: >1. apply this patch >2. prove t/db_dependent/Koha/REST/Plugin/Objects.t > >Test should fail at this point. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Koha/REST/Plugin/Objects.t | 37 ++++++++++++++++++++--- > 1 file changed, 32 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t >index a65d949fc6..3575bbbdcc 100644 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -17,6 +17,7 @@ > > use Modern::Perl; > use Koha::Cities; >+use Koha::Holds; > > # Dummy app for testing the plugin > use Mojolicious::Lite; >@@ -58,6 +59,16 @@ get '/cities_sorted' => sub { > $c->render( status => 200, json => $cities ); > }; > >+get '/patrons/:patron_id/holds' => sub { >+ my $c = shift; >+ my $params = $c->req->params->to_hash; >+ $params->{patron_id} = $c->stash("patron_id"); >+ $c->validation->output($params); >+ my $holds_set = Koha::Holds->new; >+ my $holds = $c->objects->search( $holds_set ); >+ $c->render( status => 200, json => {count => scalar(@$holds)} ); >+}; >+ > sub to_model { > my $params = shift; > >@@ -79,15 +90,13 @@ sub to_api { > } > > # The tests >-use Test::More tests => 2; >+use Test::More tests => 3; > use Test::Mojo; > > use t::lib::TestBuilder; > use Koha::Database; > >-my $schema = Koha::Database->new()->schema(); >- >- >+my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > > subtest 'objects.search helper' => sub { >@@ -273,4 +282,22 @@ subtest 'objects.search helper, sorting on mapped column' => sub { > ->json_is('/1/nombre' => 'A'); > > $schema->storage->txn_rollback; >-} >+}; >+ >+subtest 'objects.search helper, with path parameters and _match' => sub { >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ Koha::Holds->search()->delete; >+ >+ $builder->build_object({class=>"Koha::Holds", value => {borrowernumber => 10 }}); >+ >+ $t->get_ok('/patrons/1/holds?_match=exact') >+ ->json_is('/count' => 0, 'there should be no holds for borrower 1 with _match=exact'); >+ >+ $t->get_ok('/patrons/1/holds?_match=contains') >+ ->json_is('/count' => 0, 'there should be no holds for borrower 1 with _match=contains'); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.24.2 (Apple Git-127)
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 24487
:
97765
|
97772
|
97774
|
97775
|
97782
|
98029
|
98030
|
98031
|
98164
|
98165
|
98166
|
103105
|
103106
|
103107
| 103142 |
103143
|
103144