Bugzilla – Attachment 128666 Details for
Bug 29503
GET /patrons should use Koha::Patrons->search_limited
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29503: Regression tests
Bug-29503-Regression-tests.patch (text/plain), 3.24 KB, created by
Nick Clemens (kidclamp)
on 2021-12-17 14:17:08 UTC
(
hide
)
Description:
Bug 29503: Regression tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-12-17 14:17:08 UTC
Size:
3.24 KB
patch
obsolete
>From 7c6409dad2b70722061d9194335dd4edc9d1ddb4 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 17 Nov 2021 13:07:07 -0300 >Subject: [PATCH] Bug 29503: Regression tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/api/v1/patrons.t | 53 ++++++++++++++++++++++++++++++++- > 1 file changed, 52 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index c3726f54bb..1201629ffd 100755 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -43,7 +43,8 @@ my $t = Test::Mojo->new('Koha::REST::V1'); > t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > > subtest 'list() tests' => sub { >- plan tests => 2; >+ >+ plan tests => 3; > > $schema->storage->txn_begin; > unauthorized_access_tests('GET', undef, undef); >@@ -140,6 +141,56 @@ subtest 'list() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+ subtest 'search_limited() tests' => sub { >+ >+ plan tests => 9; >+ >+ $schema->storage->txn_begin; >+ >+ my $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $library_2 = $builder->build_object({ class => 'Koha::Libraries' }); >+ >+ my $patron_1 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library_1->id } }); >+ my $patron_2 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library_1->id } }); >+ my $patron_3 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library_2->id } }); >+ >+ my @libraries_where_can_see_patrons = ($library_1->id, $library_2->id); >+ >+ my $mocked_patron = Test::MockModule->new('Koha::Patron'); >+ $mocked_patron->mock( 'libraries_where_can_see_patrons', sub >+ { >+ return @libraries_where_can_see_patrons; >+ } >+ ); >+ >+ my $librarian = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 2**4 } # borrowers flag = 4 >+ } >+ ); >+ my $password = 'thePassword123'; >+ $librarian->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $librarian->userid; >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons?_order_by=patron_id&q=" . encode_json({ library_id => [ $library_1->id, $library_2->id ] })) >+ ->status_is(200) >+ ->json_is( '/0/patron_id' => $patron_1->id ) >+ ->json_is( '/1/patron_id' => $patron_2->id ) >+ ->json_is( '/2/patron_id' => $patron_3->id ); >+ >+ @libraries_where_can_see_patrons = ($library_2->id); >+ >+ my $res = $t->get_ok("//$userid:$password@/api/v1/patrons?_order_by=patron_id&q=" . encode_json({ library_id => [ $library_1->id, $library_2->id ] })) >+ ->status_is(200) >+ ->json_is( '/0/patron_id' => $patron_3->id, 'Returns the only allowed patron' ) >+ ->tx->res->json; >+ >+ is( scalar @{$res}, 1, 'Only one patron returned' ); >+ >+ $schema->storage->txn_rollback; >+ }; > }; > > subtest 'get() tests' => sub { >-- >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 29503
:
127735
|
127736
|
127737
|
127738
| 128666 |
128667