Bugzilla – Attachment 69463 Details for
Bug 19686
Add to_model and to_api params to objects.search helper
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19686: Unit tests
Bug-19686-Unit-tests.patch (text/plain), 2.88 KB, created by
David Bourgault
on 2017-12-01 21:55:44 UTC
(
hide
)
Description:
Bug 19686: Unit tests
Filename:
MIME Type:
Creator:
David Bourgault
Created:
2017-12-01 21:55:44 UTC
Size:
2.88 KB
patch
obsolete
>From 3dc239125050e04a929e61bd7c5a5cb457fc725e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 23 Nov 2017 17:10:13 -0300 >Subject: [PATCH] Bug 19686: Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Bourgault <david.bourgault@inlibro.com> >--- > t/db_dependent/Koha/REST/Plugin/Objects.t | 56 ++++++++++++++++++++++++++++++- > 1 file changed, 55 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t >index 46eed8f..5595061 100644 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -34,6 +34,23 @@ get '/patrons' => sub { > $c->render( status => 200, json => $patrons ); > }; > >+get '/patrons_to_model' => sub { >+ my $c = shift; >+ $c->validation->output($c->req->params->to_hash); >+ my $patrons_set = Koha::Patrons->new; >+ my $patrons = $c->objects->search( $patrons_set, \&_to_model ); >+ $c->render( status => 200, json => $patrons ); >+}; >+ >+sub _to_model { >+ my $params = shift; >+ >+ if ( exists $params->{nombre} ) { >+ $params->{firstname} = delete $params->{nombre}; >+ } >+ >+ return $params; >+} > > # The tests > use Test::More tests => 1; >@@ -49,7 +66,7 @@ my $builder = t::lib::TestBuilder->new; > > subtest 'objects.search helper' => sub { > >- plan tests => 34; >+ plan tests => 62; > > my $t = Test::Mojo->new; > >@@ -121,5 +138,42 @@ subtest 'objects.search helper' => sub { > ->json_is('/1/firstname' => 'Manuela') > ->json_is('/2/firstname' => 'Emanuel'); > >+ ## _to_model tests >+ # _match=starts_with >+ $t->get_ok('/patrons_to_model?nombre=manuel&_per_page=3&_page=1&_match=starts_with') >+ ->status_is(200) >+ ->json_has('/0') >+ ->json_has('/1') >+ ->json_hasnt('/2') >+ ->json_is('/0/firstname' => 'Manuel') >+ ->json_is('/1/firstname' => 'Manuela'); >+ >+ # _match=ends_with >+ $t->get_ok('/patrons_to_model?nombre=manuel&_per_page=3&_page=1&_match=ends_with') >+ ->status_is(200) >+ ->json_has('/0') >+ ->json_has('/1') >+ ->json_hasnt('/2') >+ ->json_is('/0/firstname' => 'Manuel') >+ ->json_is('/1/firstname' => 'Emanuel'); >+ >+ # _match=exact >+ $t->get_ok('/patrons_to_model?nombre=manuel&_per_page=3&_page=1&_match=exact') >+ ->status_is(200) >+ ->json_has('/0') >+ ->json_hasnt('/1') >+ ->json_is('/0/firstname' => 'Manuel'); >+ >+ # _match=contains >+ $t->get_ok('/patrons_to_model?nombre=manuel&_per_page=3&_page=1&_match=contains') >+ ->status_is(200) >+ ->json_has('/0') >+ ->json_has('/1') >+ ->json_has('/2') >+ ->json_hasnt('/3') >+ ->json_is('/0/firstname' => 'Manuel') >+ ->json_is('/1/firstname' => 'Manuela') >+ ->json_is('/2/firstname' => 'Emanuel'); >+ > $schema->storage->txn_rollback; > }; >-- >2.7.4
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 19686
:
69315
|
69316
|
69463
|
69464
|
70626
|
71742
|
71743
|
71744