Bugzilla – Attachment 126164 Details for
Bug 27358
Add GET /public/biblios/:biblio_id/items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27358: Unit tests for public items retrieval
Bug-27358-Unit-tests-for-public-items-retrieval.patch (text/plain), 3.43 KB, created by
Martin Renvoize (ashimema)
on 2021-10-13 09:42:14 UTC
(
hide
)
Description:
Bug 27358: Unit tests for public items retrieval
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-10-13 09:42:14 UTC
Size:
3.43 KB
patch
obsolete
>From d76fde1a0abd510bef9b346ae3fd405e3fce4cc6 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 7 Jan 2021 15:38:54 -0300 >Subject: [PATCH] Bug 27358: Unit tests for public items retrieval > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/api/v1/biblios.t | 86 ++++++++++++++++++++++++++++++++- > 1 file changed, 85 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t >index 25665ed5cf..15a5258cee 100755 >--- a/t/db_dependent/api/v1/biblios.t >+++ b/t/db_dependent/api/v1/biblios.t >@@ -20,7 +20,7 @@ use Modern::Perl; > use utf8; > use Encode; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Test::MockModule; > use Test::Mojo; > use Test::Warn; >@@ -494,3 +494,87 @@ subtest 'pickup_locations() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'get_items_public() tests' => sub { >+ >+ plan tests => 15; >+ >+ $schema->storage->txn_begin; >+ >+ my $override_hidden_items = 0; >+ >+ my $mocked_category = Test::MockModule->new('Koha::Patron::Category'); >+ $mocked_category->mock( >+ 'override_hidden_items', >+ sub { >+ return $override_hidden_items; >+ } >+ ); >+ >+ my $rules = undef; >+ >+ my $mocked_context = Test::MockModule->new('C4::Context'); >+ $mocked_context->mock( >+ 'yaml_preference', >+ sub { >+ return $rules; >+ } >+ ); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ $patron->discard_changes; >+ my $userid = $patron->userid; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ >+ $t->get_ok( >+ "//$userid:$password@/api/v1/public/biblios/" . $biblio->id . "/items" ) >+ ->status_is(200)->json_is( '' => [], 'No items on the biblio' ); >+ >+ my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->id } ); >+ my $item_2 = $builder->build_sample_item( >+ { biblionumber => $biblio->id, withdrawn => 1 } ); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/public/biblios/" >+ . $biblio->biblionumber >+ . "/items" )->status_is(200)->json_is( >+ '' => [ >+ $item_1->to_api( { public => 1 } ), >+ $item_2->to_api( { public => 1 } ) >+ ], >+ 'The items are returned' >+ ); >+ >+ $rules = { withdrawn => ['1'] }; >+ >+ $t->get_ok( "//$userid:$password@/api/v1/public/biblios/" >+ . $biblio->biblionumber >+ . "/items" )->status_is(200)->json_is( >+ '' => [ $item_1->to_api( { public => 1 } ) ], >+ 'The items are returned, hidden one is not returned' >+ ); >+ >+ $t->get_ok( "/api/v1/public/biblios/" >+ . $biblio->biblionumber >+ . "/items" )->status_is(200)->json_is( >+ '' => [ $item_1->to_api( { public => 1 } ) ], >+ 'Anonymous user, items are returned, hidden one is not returned' >+ ); >+ >+ >+ $override_hidden_items = 1; >+ >+ $t->get_ok( "//$userid:$password@/api/v1/public/biblios/" >+ . $biblio->biblionumber >+ . "/items" )->status_is(200)->json_is( >+ '' => [ >+ $item_1->to_api( { public => 1 } ), >+ $item_2->to_api( { public => 1 } ) >+ ], >+ 'The items are returned, the patron category has an override' >+ ); >+ >+ $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 27358
:
114922
|
114935
|
114936
|
114937
|
114938
|
114939
|
116187
|
116188
|
116189
|
116190
|
116191
|
123843
|
123844
|
123845
|
123846
|
123847
|
124454
|
124455
|
124456
|
124457
|
124458
|
124459
|
126156
|
126157
|
126158
|
126159
|
126164
|
126165
|
126971
|
126972