Bugzilla – Attachment 127528 Details for
Bug 26636
Add objects.find Mojolicious helper
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26636: Add tests [20.11.x]
Bug-26636-Add-tests-2011x.patch (text/plain), 3.53 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-11-11 11:34:14 UTC
(
hide
)
Description:
Bug 26636: Add tests [20.11.x]
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-11-11 11:34:14 UTC
Size:
3.53 KB
patch
obsolete
>From 005c3a531061011c51bc95ef792bae28e7d5bc0b Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Fri, 9 Oct 2020 11:53:43 -0300 >Subject: [PATCH] Bug 26636: Add tests [20.11.x] > >This patch adds tests for the new objects.find helper. > >Sponsored-by: Virginia Polytechnic Institute and State University > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/REST/Plugin/Objects.t | 60 ++++++++++++++++++++++- > 1 file changed, 58 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t >index af656f32d5..6155e58f57 100755 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -38,6 +38,13 @@ get '/cities' => sub { > $c->render( status => 200, json => $cities ); > }; > >+get '/cities/:city_id' => sub { >+ my $c = shift; >+ my $id = $c->stash("city_id"); >+ my $city = $c->objects->find(Koha::Cities->new, $id); >+ $c->render( status => 200, json => $city ); >+}; >+ > get '/orders' => sub { > my $c = shift; > $c->stash('koha.embed', ( { fund => {} } ) ); >@@ -56,6 +63,14 @@ get '/patrons/:patron_id/holds' => sub { > $c->render( status => 200, json => {count => scalar(@$holds)} ); > }; > >+get '/orders/:order_id' => sub { >+ my $c = shift; >+ $c->stash('koha.embed', ( { fund => {} } ) ); >+ my $id = $c->stash("order_id"); >+ my $order = $c->objects->find(Koha::Acquisition::Orders->new, $id); >+ $c->render( status => 200, json => $order ); >+}; >+ > get '/biblios' => sub { > my $c = shift; > my $output = $c->req->params->to_hash; >@@ -77,7 +92,7 @@ get '/biblios' => sub { > > > # The tests >-use Test::More tests => 10; >+use Test::More tests => 12; > use Test::Mojo; > > use t::lib::Mocks; >@@ -444,8 +459,11 @@ subtest 'object.search helper with all query methods' => sub { > }; > > subtest 'object.search helper order by embedded columns' => sub { >+ > plan tests => 3; > >+ $schema->storage->txn_begin; >+ > my $patron1 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron1'} } ); > my $patron2 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron2'} } ); > my $biblio1 = $builder->build_sample_biblio; >@@ -458,5 +476,43 @@ subtest 'object.search helper order by embedded columns' => sub { > ->json_is('/biblios/0/biblio_id' => $biblio2->biblionumber, 'Biblio 2 should be first') > ->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); > >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'objects.find helper' => sub { >+ >+ plan tests => 6; >+ >+ my $t = Test::Mojo->new; >+ > $schema->storage->txn_begin; >-} >+ >+ my $city_1 = $builder->build_object( { class => 'Koha::Cities' } ); >+ my $city_2 = $builder->build_object( { class => 'Koha::Cities' } ); >+ >+ $t->get_ok( '/cities/' . $city_1->id ) >+ ->status_is(200) >+ ->json_is( $city_1->to_api ); >+ >+ $t->get_ok( '/cities/' . $city_2->id ) >+ ->status_is(200) >+ ->json_is( $city_2->to_api ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'objects.find helper, embed' => sub { >+ >+ plan tests => 2; >+ >+ my $t = Test::Mojo->new; >+ >+ $schema->storage->txn_begin; >+ >+ my $order = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); >+ >+ $t->get_ok( '/orders/' . $order->ordernumber ) >+ ->json_is( $order->to_api( { embed => ( { fund => {} } ) } ) ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.33.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 26636
:
111418
|
111419
|
116222
|
116223
|
116224
|
116225
|
116226
|
116227
|
116228
|
116229
|
116230
|
116231
|
116594
|
116595
|
116596
|
116597
|
116598
|
117669
|
117670
|
117671
|
117672
|
117673
| 127528 |
127529
|
127530
|
127531
|
127532