Bugzilla – Attachment 116222 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.34 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-02-02 19:52:35 UTC
(
hide
)
Description:
Bug 26636: Add tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-02-02 19:52:35 UTC
Size:
3.34 KB
patch
obsolete
>From a87282246fc2fea7637804b0d8728c144162604e 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 Tech Libraries >--- > 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 60c9f811921..c8af770a805 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; >@@ -397,8 +412,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; >@@ -411,5 +429,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.30.0
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