Bugzilla – Attachment 117669 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
Bug-26636-Add-tests.patch (text/plain), 3.49 KB, created by
Martin Renvoize (ashimema)
on 2021-03-04 10:34:10 UTC
(
hide
)
Description:
Bug 26636: Add tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-03-04 10:34:10 UTC
Size:
3.49 KB
patch
obsolete
>From b32799958895f273e32f661caccf86689bf749b1 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 > >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 299e6b1b20..2f4937f89d 100755 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -37,6 +37,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 => {} } ) ); >@@ -45,6 +52,14 @@ get '/orders' => sub { > $c->render( status => 200, json => $orders ); > }; > >+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; >@@ -65,7 +80,7 @@ get '/biblios' => sub { > }; > > # The tests >-use Test::More tests => 10; >+use Test::More tests => 12; > use Test::Mojo; > > use t::lib::Mocks; >@@ -433,8 +448,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; >@@ -447,5 +465,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.20.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